提交 5822e8cc 编写于 作者: Y Yang Yingliang 提交者: Thomas Bogendoerfer

MIPS: vpe-mt: fix possible memory leak while module exiting

Afer commit 1fa5ae85 ("driver core: get rid of struct device's
bus_id string array"), the name of device is allocated dynamically,
it need be freed when module exiting, call put_device() to give up
reference, so that it can be freed in kobject_cleanup() when the
refcount hit to 0. The vpe_device is static, so remove kfree() from
vpe_device_release().

Fixes: 1fa5ae85 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NThomas Bogendoerfer <tsbogend@alpha.franken.de>
上级 0e2e1216
...@@ -313,7 +313,6 @@ ATTRIBUTE_GROUPS(vpe); ...@@ -313,7 +313,6 @@ ATTRIBUTE_GROUPS(vpe);
static void vpe_device_release(struct device *cd) static void vpe_device_release(struct device *cd)
{ {
kfree(cd);
} }
static struct class vpe_class = { static struct class vpe_class = {
...@@ -497,6 +496,7 @@ int __init vpe_module_init(void) ...@@ -497,6 +496,7 @@ int __init vpe_module_init(void)
device_del(&vpe_device); device_del(&vpe_device);
out_class: out_class:
put_device(&vpe_device);
class_unregister(&vpe_class); class_unregister(&vpe_class);
out_chrdev: out_chrdev:
...@@ -509,7 +509,7 @@ void __exit vpe_module_exit(void) ...@@ -509,7 +509,7 @@ void __exit vpe_module_exit(void)
{ {
struct vpe *v, *n; struct vpe *v, *n;
device_del(&vpe_device); device_unregister(&vpe_device);
class_unregister(&vpe_class); class_unregister(&vpe_class);
unregister_chrdev(major, VPE_MODULE_NAME); unregister_chrdev(major, VPE_MODULE_NAME);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册