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: Lin Yi <teroincn@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Lin Yi 2019-06-03 16:08:10 +08:00 committed by Greg Kroah-Hartman
parent 5666d896e8
commit 122f8ec7b7

View File

@ -498,8 +498,10 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
kobj = kobject_get(kobj);
if (!kobj)
return -EINVAL;
if (!kobj->parent)
if (!kobj->parent) {
kobject_put(kobj);
return -EINVAL;
}
devpath = kobject_get_path(kobj, GFP_KERNEL);
if (!devpath) {