提交 82189b98 编写于 作者: C Catalin Marinas 提交者: Linus Torvalds

[PATCH] Fix device_attribute memory leak in device_del

dev->devt_attr is allocated in device_add() but it is never freed in
device_del() in the drivers/base/core.c file (reported by kmemleak).
Signed-off-by: NCatalin Marinas <catalin.marinas@gmail.com>
Acked-by: NGreg KH <greg@kroah.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 533221fb
......@@ -591,8 +591,10 @@ void device_del(struct device * dev)
if (parent)
klist_del(&dev->knode_parent);
if (dev->devt_attr)
if (dev->devt_attr) {
device_remove_file(dev, dev->devt_attr);
kfree(dev->devt_attr);
}
if (dev->class) {
sysfs_remove_link(&dev->kobj, "subsystem");
sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册