Skip to content

Commit 0ffddaf

Browse files
Wang Haiteigland
authored andcommitted
dlm: Fix kobject memleak
Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject. Set do_unreg = 1 before kobject_init_and_add() to ensure that kobject_put() can be called in its error patch. Fixes: 901195e ("Kobject: change GFS2 to use kobject_init_and_add") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Wang Hai <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 4877846 commit 0ffddaf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/dlm/lockspace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,16 +622,16 @@ static int new_lockspace(const char *name, const char *cluster,
622622
wait_event(ls->ls_recover_lock_wait,
623623
test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags));
624624

625+
/* let kobject handle freeing of ls if there's an error */
626+
do_unreg = 1;
627+
625628
ls->ls_kobj.kset = dlm_kset;
626629
error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
627630
"%s", ls->ls_name);
628631
if (error)
629632
goto out_recoverd;
630633
kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
631634

632-
/* let kobject handle freeing of ls if there's an error */
633-
do_unreg = 1;
634-
635635
/* This uevent triggers dlm_controld in userspace to add us to the
636636
group of nodes that are members of this lockspace (managed by the
637637
cluster infrastructure.) Once it's done that, it tells us who the

0 commit comments

Comments
 (0)