diff options
author | Lin Yi <teroincn@163.com> | 2019-06-03 04:08:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-19 13:27:39 -0400 |
commit | 122f8ec7b78e2d0f2dc6c966bef96b47c955ca36 (patch) | |
tree | 43ff22835eb5fbe2d3d137f2d117eb00a7c00928 /lib/kobject.c | |
parent | 5666d896e838c974c535b3949353c83d68ce4384 (diff) |
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>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r-- | lib/kobject.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index f2ccdbac8ed9..83198cb37d8d 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -498,8 +498,10 @@ int kobject_rename(struct kobject *kobj, const char *new_name) | |||
498 | kobj = kobject_get(kobj); | 498 | kobj = kobject_get(kobj); |
499 | if (!kobj) | 499 | if (!kobj) |
500 | return -EINVAL; | 500 | return -EINVAL; |
501 | if (!kobj->parent) | 501 | if (!kobj->parent) { |
502 | kobject_put(kobj); | ||
502 | return -EINVAL; | 503 | return -EINVAL; |
504 | } | ||
503 | 505 | ||
504 | devpath = kobject_get_path(kobj, GFP_KERNEL); | 506 | devpath = kobject_get_path(kobj, GFP_KERNEL); |
505 | if (!devpath) { | 507 | if (!devpath) { |