Commit 122f8ec7 authored by Lin Yi's avatar Lin Yi Committed by Greg Kroah-Hartman

lib : kobject: fix refcount imblance on kobject_rename

the kobj refcount increased by kobject_get should be released before
error return, otherwise lead to a memory leak.
Signed-off-by: default avatarLin Yi <teroincn@163.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5666d896
...@@ -498,8 +498,10 @@ int kobject_rename(struct kobject *kobj, const char *new_name) ...@@ -498,8 +498,10 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
kobj = kobject_get(kobj); kobj = kobject_get(kobj);
if (!kobj) if (!kobj)
return -EINVAL; return -EINVAL;
if (!kobj->parent) if (!kobj->parent) {
kobject_put(kobj);
return -EINVAL; return -EINVAL;
}
devpath = kobject_get_path(kobj, GFP_KERNEL); devpath = kobject_get_path(kobj, GFP_KERNEL);
if (!devpath) { if (!devpath) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment