diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2006-09-28 23:56:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-18 12:49:55 -0700 |
commit | 952ab431cd36c7ab573f685af8679c3677cbdc29 (patch) | |
tree | 91a7ca161516c4ceb6e0500a505bf94600d7db60 /drivers/base/core.c | |
parent | 221c324a336770a911b16bda02b9f4adad506a35 (diff) | |
download | kernel_samsung_tuna-952ab431cd36c7ab573f685af8679c3677cbdc29.zip kernel_samsung_tuna-952ab431cd36c7ab573f685af8679c3677cbdc29.tar.gz kernel_samsung_tuna-952ab431cd36c7ab573f685af8679c3677cbdc29.tar.bz2 |
Driver core: Don't leak 'old_class_name' in drivers/base/core.c::device_rename()
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>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | 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, char *new_name) 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, char *new_name) } 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; } |