From: Jesper Juhl <jesper.juhl@gmail.com> If kmalloc() fails to allocate space for 'old_symlink_name' in drivers/base/core.c::device_rename(), then we'll leak 'old_class_name'. Spotted by the Coverity checker. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- drivers/base/core.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 365f709..41f3dca 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -809,8 +809,10 @@ int device_rename(struct device *dev, ch if (dev->class) { old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); - if (!old_symlink_name) - return -ENOMEM; + if (!old_symlink_name) { + error = -ENOMEM; + goto out_free_old_class; + } strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE); } @@ -834,9 +836,10 @@ int device_rename(struct device *dev, ch } put_device(dev); - kfree(old_class_name); kfree(new_class_name); kfree(old_symlink_name); + out_free_old_class: + kfree(old_class_name); return error; } -- 1.4.2.4 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- [PATCH 14/16] Driver core: Don't ignore error returns from probing
- From: Greg KH <greg@kroah.com>
- [PATCH 14/16] Driver core: Don't ignore error returns from probing
- References:
- [GIT PATCH] Driver Core fixes for 2.6.19-rc2
- From: Greg KH <gregkh@suse.de>
- [PATCH 1/16] Documentation: feature-removal-schedule typo
- From: Greg KH <greg@kroah.com>
- [PATCH 2/16] Driver core: plug device probe memory leak
- From: Greg KH <greg@kroah.com>
- [PATCH 3/16] Fix dev_printk() is now GPL-only
- From: Greg KH <greg@kroah.com>
- [PATCH 4/16] HOWTO: bug report addition
- From: Greg KH <greg@kroah.com>
- [PATCH 5/16] sysfs: remove duplicated dput in sysfs_update_file
- From: Greg KH <greg@kroah.com>
- [PATCH 6/16] sysfs: update obsolete comment in sysfs_update_file
- From: Greg KH <greg@kroah.com>
- [PATCH 7/16] driver core fixes: sysfs_create_link() retval check in class.c
- From: Greg KH <greg@kroah.com>
- [PATCH 8/16] driver core fixes: bus_add_attrs() retval check
- From: Greg KH <greg@kroah.com>
- [PATCH 9/16] driver core fixes: bus_add_device() cleanup on error
- From: Greg KH <greg@kroah.com>
- [PATCH 10/16] driver core fixes: device_add() cleanup on error
- From: Greg KH <greg@kroah.com>
- [PATCH 11/16] driver core fixes: device_create_file() retval check in dmapool.c
- From: Greg KH <greg@kroah.com>
- [PATCH 12/16] driver core fixes: sysfs_create_group() retval in topology.c
- From: Greg KH <greg@kroah.com>
- [GIT PATCH] Driver Core fixes for 2.6.19-rc2
- Prev by Date: [PATCH 2/15] aoe: update copyright date
- Next by Date: Re: [PATCH 5/6] isdn/hisax: use bitrev8
- Previous by thread: [PATCH 12/16] driver core fixes: sysfs_create_group() retval in topology.c
- Next by thread: [PATCH 14/16] Driver core: Don't ignore error returns from probing
- Index(es):
![]() |