mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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:
parent
5666d896e8
commit
122f8ec7b7
1 changed files with 3 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue