diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2006-09-28 17:56:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-18 15:49:55 -0400 |
commit | 952ab431cd36c7ab573f685af8679c3677cbdc29 (patch) | |
tree | 91a7ca161516c4ceb6e0500a505bf94600d7db60 /drivers/base | |
parent | 221c324a336770a911b16bda02b9f4adad506a35 (diff) |
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')
-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 365f709715ef..41f3dca55cd0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -809,8 +809,10 @@ int device_rename(struct device *dev, char *new_name) | |||
809 | 809 | ||
810 | if (dev->class) { | 810 | if (dev->class) { |
811 | old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); | 811 | old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); |
812 | if (!old_symlink_name) | 812 | if (!old_symlink_name) { |
813 | return -ENOMEM; | 813 | error = -ENOMEM; |
814 | goto out_free_old_class; | ||
815 | } | ||
814 | strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE); | 816 | strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE); |
815 | } | 817 | } |
816 | 818 | ||
@@ -834,9 +836,10 @@ int device_rename(struct device *dev, char *new_name) | |||
834 | } | 836 | } |
835 | put_device(dev); | 837 | put_device(dev); |
836 | 838 | ||
837 | kfree(old_class_name); | ||
838 | kfree(new_class_name); | 839 | kfree(new_class_name); |
839 | kfree(old_symlink_name); | 840 | kfree(old_symlink_name); |
841 | out_free_old_class: | ||
842 | kfree(old_class_name); | ||
840 | 843 | ||
841 | return error; | 844 | return error; |
842 | } | 845 | } |