Skip to content

Commit d24846a

Browse files
Yuuoniyhdeller
authored andcommitted
parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries
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: 73f368c ("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>
1 parent 30f3089 commit d24846a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/parisc/pdc_stable.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,10 @@ pdcs_register_pathentries(void)
980980
entry->kobj.kset = paths_kset;
981981
err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL,
982982
"%s", entry->name);
983-
if (err)
983+
if (err) {
984+
kobject_put(&entry->kobj);
984985
return err;
986+
}
985987

986988
/* kobject is now registered */
987989
write_lock(&entry->rw_lock);

0 commit comments

Comments
 (0)