[DLM] fix new_lockspace error exit [5/6]
Fix the error path when exiting new_lockspace(). It was kfree'ing the lockspace struct at the end, but that's only valid if it exits before kobject_register occured. After kobject_register we have to let the kobject do the freeing. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
committed by
Steven Whitehouse
parent
c85d65e914
commit
79d72b5448
@@ -400,6 +400,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
|
|||||||
{
|
{
|
||||||
struct dlm_ls *ls;
|
struct dlm_ls *ls;
|
||||||
int i, size, error = -ENOMEM;
|
int i, size, error = -ENOMEM;
|
||||||
|
int do_unreg = 0;
|
||||||
|
|
||||||
if (namelen > DLM_LOCKSPACE_LEN)
|
if (namelen > DLM_LOCKSPACE_LEN)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -525,32 +526,34 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
|
|||||||
error = dlm_recoverd_start(ls);
|
error = dlm_recoverd_start(ls);
|
||||||
if (error) {
|
if (error) {
|
||||||
log_error(ls, "can't start dlm_recoverd %d", error);
|
log_error(ls, "can't start dlm_recoverd %d", error);
|
||||||
goto out_rcomfree;
|
goto out_delist;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlm_create_debug_file(ls);
|
|
||||||
|
|
||||||
error = kobject_setup(ls);
|
error = kobject_setup(ls);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_del;
|
goto out_stop;
|
||||||
|
|
||||||
error = kobject_register(&ls->ls_kobj);
|
error = kobject_register(&ls->ls_kobj);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_del;
|
goto out_stop;
|
||||||
|
|
||||||
|
/* let kobject handle freeing of ls if there's an error */
|
||||||
|
do_unreg = 1;
|
||||||
|
|
||||||
error = do_uevent(ls, 1);
|
error = do_uevent(ls, 1);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_unreg;
|
goto out_stop;
|
||||||
|
|
||||||
|
dlm_create_debug_file(ls);
|
||||||
|
|
||||||
|
log_debug(ls, "join complete");
|
||||||
|
|
||||||
*lockspace = ls;
|
*lockspace = ls;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unreg:
|
out_stop:
|
||||||
kobject_unregister(&ls->ls_kobj);
|
|
||||||
out_del:
|
|
||||||
dlm_delete_debug_file(ls);
|
|
||||||
dlm_recoverd_stop(ls);
|
dlm_recoverd_stop(ls);
|
||||||
out_rcomfree:
|
out_delist:
|
||||||
spin_lock(&lslist_lock);
|
spin_lock(&lslist_lock);
|
||||||
list_del(&ls->ls_list);
|
list_del(&ls->ls_list);
|
||||||
spin_unlock(&lslist_lock);
|
spin_unlock(&lslist_lock);
|
||||||
@@ -562,6 +565,9 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
|
|||||||
out_rsbfree:
|
out_rsbfree:
|
||||||
kfree(ls->ls_rsbtbl);
|
kfree(ls->ls_rsbtbl);
|
||||||
out_lsfree:
|
out_lsfree:
|
||||||
|
if (do_unreg)
|
||||||
|
kobject_unregister(&ls->ls_kobj);
|
||||||
|
else
|
||||||
kfree(ls);
|
kfree(ls);
|
||||||
out:
|
out:
|
||||||
module_put(THIS_MODULE);
|
module_put(THIS_MODULE);
|
||||||
|
Reference in New Issue
Block a user