From: Catalin Marinas Date: Sat, 25 Nov 2006 19:09:30 +0000 (-0800) Subject: [PATCH] Fix device_attribute memory leak in device_del X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=82189b9807e05ea8d1f69de5bf92eaf244a0eb12;p=openwrt%2Fstaging%2Fblogic.git [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: Catalin Marinas Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/base/core.c b/drivers/base/core.c index 68ad11af22b4..002fde46d38d 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);