mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 03:40:04 +00:00
parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries
commitd24846a424
upstream. kobject_init_and_add() takes reference even when it fails. According to the doc of kobject_init_and_add(): If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Fix memory leak by calling kobject_put(). Fixes:73f368cf67
("Kobject: change drivers/parisc/pdc_stable.c to use kobject_init_and_add") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d25fe9c255
commit
f852afb6c0
1 changed files with 3 additions and 1 deletions
|
@ -979,8 +979,10 @@ pdcs_register_pathentries(void)
|
||||||
entry->kobj.kset = paths_kset;
|
entry->kobj.kset = paths_kset;
|
||||||
err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL,
|
err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL,
|
||||||
"%s", entry->name);
|
"%s", entry->name);
|
||||||
if (err)
|
if (err) {
|
||||||
|
kobject_put(&entry->kobj);
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/* kobject is now registered */
|
/* kobject is now registered */
|
||||||
write_lock(&entry->rw_lock);
|
write_lock(&entry->rw_lock);
|
||||||
|
|
Loading…
Reference in a new issue