projects/linux·commit 82189b98

[PATCH] Fix device_attribute memory leak in device_del

82189b98 · Catalin Marinas <[email protected]> · 2006-11-25 11:09:30 -08:00

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 <[email protected]>
Acked-by: Greg KH <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
82189b9807e05ea8d1f69de5bf92eaf244a0eb12
Parents
533221fb

Changes

1 files changed · +3 −1

FileStatusAddDelContent
drivers/base/core.cmodified+3−1View file

drivers/base/core.c

View file
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 68ad11a..002fde4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -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);