diff options
author | David Teigland <teigland@redhat.com> | 2007-05-18 10:02:20 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-07-09 03:22:40 -0400 |
commit | 79d72b54483bf81b9f9de0dd555c710ac7267986 (patch) | |
tree | 271298ddf4864631e7afe0c54239b46e7c4a81dc /fs/dlm | |
parent | c85d65e91430db94ae9ce0cf38b56e496658b642 (diff) |
[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>
Diffstat (limited to 'fs/dlm')
-rw-r--r-- | fs/dlm/lockspace.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 339a204d7479..a3a50e67e4dd 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -400,6 +400,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
400 | { | 400 | { |
401 | struct dlm_ls *ls; | 401 | struct dlm_ls *ls; |
402 | int i, size, error = -ENOMEM; | 402 | int i, size, error = -ENOMEM; |
403 | int do_unreg = 0; | ||
403 | 404 | ||
404 | if (namelen > DLM_LOCKSPACE_LEN) | 405 | if (namelen > DLM_LOCKSPACE_LEN) |
405 | return -EINVAL; | 406 | return -EINVAL; |
@@ -525,32 +526,34 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
525 | error = dlm_recoverd_start(ls); | 526 | error = dlm_recoverd_start(ls); |
526 | if (error) { | 527 | if (error) { |
527 | log_error(ls, "can't start dlm_recoverd %d", error); | 528 | log_error(ls, "can't start dlm_recoverd %d", error); |
528 | goto out_rcomfree; | 529 | goto out_delist; |
529 | } | 530 | } |
530 | 531 | ||
531 | dlm_create_debug_file(ls); | ||
532 | |||
533 | error = kobject_setup(ls); | 532 | error = kobject_setup(ls); |
534 | if (error) | 533 | if (error) |
535 | goto out_del; | 534 | goto out_stop; |
536 | 535 | ||
537 | error = kobject_register(&ls->ls_kobj); | 536 | error = kobject_register(&ls->ls_kobj); |
538 | if (error) | 537 | if (error) |
539 | goto out_del; | 538 | goto out_stop; |
539 | |||
540 | /* let kobject handle freeing of ls if there's an error */ | ||
541 | do_unreg = 1; | ||
540 | 542 | ||
541 | error = do_uevent(ls, 1); | 543 | error = do_uevent(ls, 1); |
542 | if (error) | 544 | if (error) |
543 | goto out_unreg; | 545 | goto out_stop; |
546 | |||
547 | dlm_create_debug_file(ls); | ||
548 | |||
549 | log_debug(ls, "join complete"); | ||
544 | 550 | ||
545 | *lockspace = ls; | 551 | *lockspace = ls; |
546 | return 0; | 552 | return 0; |
547 | 553 | ||
548 | out_unreg: | 554 | out_stop: |
549 | kobject_unregister(&ls->ls_kobj); | ||
550 | out_del: | ||
551 | dlm_delete_debug_file(ls); | ||
552 | dlm_recoverd_stop(ls); | 555 | dlm_recoverd_stop(ls); |
553 | out_rcomfree: | 556 | out_delist: |
554 | spin_lock(&lslist_lock); | 557 | spin_lock(&lslist_lock); |
555 | list_del(&ls->ls_list); | 558 | list_del(&ls->ls_list); |
556 | spin_unlock(&lslist_lock); | 559 | spin_unlock(&lslist_lock); |
@@ -562,7 +565,10 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
562 | out_rsbfree: | 565 | out_rsbfree: |
563 | kfree(ls->ls_rsbtbl); | 566 | kfree(ls->ls_rsbtbl); |
564 | out_lsfree: | 567 | out_lsfree: |
565 | kfree(ls); | 568 | if (do_unreg) |
569 | kobject_unregister(&ls->ls_kobj); | ||
570 | else | ||
571 | kfree(ls); | ||
566 | out: | 572 | out: |
567 | module_put(THIS_MODULE); | 573 | module_put(THIS_MODULE); |
568 | return error; | 574 | return error; |
@@ -708,7 +714,7 @@ static int release_lockspace(struct dlm_ls *ls, int force) | |||
708 | dlm_clear_members_gone(ls); | 714 | dlm_clear_members_gone(ls); |
709 | kfree(ls->ls_node_array); | 715 | kfree(ls->ls_node_array); |
710 | kobject_unregister(&ls->ls_kobj); | 716 | kobject_unregister(&ls->ls_kobj); |
711 | /* The ls structure will be freed when the kobject is done with */ | 717 | /* The ls structure will be freed when the kobject is done with */ |
712 | 718 | ||
713 | mutex_lock(&ls_lock); | 719 | mutex_lock(&ls_lock); |
714 | ls_count--; | 720 | ls_count--; |