Skip to content

Commit

Permalink
[PATCH] Fix device_attribute memory leak in device_del
Browse files Browse the repository at this point in the history
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: Catalin Marinas <catalin.marinas@gmail.com>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Catalin Marinas authored and Linus Torvalds committed Nov 25, 2006
1 parent 533221f commit 82189b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 82189b9

Please sign in to comment.