The patch titled driver core: fix small mem leak in driver_add_kobj() has been removed from the -mm tree. Its filename was fix-small-mem-leak-in-driver_add_kobj.patch This patch was dropped because it was merged into mainline or a subsystem tree The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: driver core: fix small mem leak in driver_add_kobj() From: Jesper Juhl <jesper.juhl@xxxxxxxxx> The Coverity checker spotted that we leak the storage allocated to 'name' in int driver_add_kobj(). The leak looks legit to me - this is the code : int driver_add_kobj(struct device_driver *drv, struct kobject *kobj, const char *fmt, ...) { va_list args; char *name; int ret; va_start(args, fmt); name = kvasprintf(GFP_KERNEL, fmt, args); ^^^^^^^^ This dynamically allocates space... va_end(args); if (!name) return -ENOMEM; return kobject_add(kobj, &drv->p->kobj, "%s", name); ^^^^^^^^ This neglects to free the space allocated } Inside kobject_add() a copy of 'name' will be made and used. As far as I can see, Coverity is correct in flagging this as a leak, but I'd like some configmation before the patch is applied. This should fix it. Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Cc: Kay Sievers <kay.sievers@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/base/driver.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff -puN drivers/base/driver.c~fix-small-mem-leak-in-driver_add_kobj drivers/base/driver.c --- a/drivers/base/driver.c~fix-small-mem-leak-in-driver_add_kobj +++ a/drivers/base/driver.c @@ -133,6 +133,7 @@ int driver_add_kobj(struct device_driver { va_list args; char *name; + int ret; va_start(args, fmt); name = kvasprintf(GFP_KERNEL, fmt, args); @@ -141,7 +142,9 @@ int driver_add_kobj(struct device_driver if (!name) return -ENOMEM; - return kobject_add(kobj, &drv->p->kobj, "%s", name); + ret = kobject_add(kobj, &drv->p->kobj, "%s", name); + kfree(name); + return ret; } EXPORT_SYMBOL_GPL(driver_add_kobj); _ Patches currently in -mm which might be from jesper.juhl@xxxxxxxxx are origin.patch pci-hotplug-fix-leaks-in-ibm-hot-plug-controller-driver-ibmphp_init_devno.patch git-sh.patch usb-mem-leak-fixes-for-amd-5536-udc-high-full-speed-usb-device-controller-driver.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html