summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2006-09-28 23:56:01 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 12:49:55 -0700
commit952ab431cd36c7ab573f685af8679c3677cbdc29 (patch)
tree91a7ca161516c4ceb6e0500a505bf94600d7db60 /drivers/base
parent221c324a336770a911b16bda02b9f4adad506a35 (diff)
downloadblackbird-op-linux-952ab431cd36c7ab573f685af8679c3677cbdc29.tar.gz
blackbird-op-linux-952ab431cd36c7ab573f685af8679c3677cbdc29.zip
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.c9
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)
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;
}
OpenPOWER on IntegriCloud