提交 0894f746 编写于 作者: L Liu Jian 提交者: Xie XiuQi

driver: uio: fix possible memory leak in __uio_register_device

mainline inclusion
from mainline-5.x
commit: 1a392b3d
category: bugfix
bugzilla: NA
CVE: NA

---------------------------

'idev' is malloced in __uio_register_device() and leak free it before
leaving from the uio_get_minor() error handing case, it will cause
memory leak.

Fixes: a93e7b33 ("uio: Prevent device destruction while fds are open")
Signed-off-by: NLiu Jian <liujian56@huawei.com>
Reviewed-by: NHamish Martin <hamish.martin@alliedtelesis.co.nz>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NLiu Jian <liujian56@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 532c3c62
...@@ -938,8 +938,10 @@ int __uio_register_device(struct module *owner, ...@@ -938,8 +938,10 @@ int __uio_register_device(struct module *owner,
atomic_set(&idev->event, 0); atomic_set(&idev->event, 0);
ret = uio_get_minor(idev); ret = uio_get_minor(idev);
if (ret) if (ret) {
kfree(idev);
return ret; return ret;
}
idev->dev.devt = MKDEV(uio_major, idev->minor); idev->dev.devt = MKDEV(uio_major, idev->minor);
idev->dev.class = &uio_class; idev->dev.class = &uio_class;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册