Skip to content

Commit 0f6187d

Browse files
Wei Yongjunshligit
authored andcommitted
md-cluster: fix error return code in join()
Fix to return error code -ENOMEM from the lockres_init() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent 486b0f7 commit 0f6187d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/md/md-cluster.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,10 @@ static int join(struct mddev *mddev, int nodes)
834834
goto err;
835835
}
836836
cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
837-
if (!cinfo->ack_lockres)
837+
if (!cinfo->ack_lockres) {
838+
ret = -ENOMEM;
838839
goto err;
840+
}
839841
/* get sync CR lock on ACK. */
840842
if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
841843
pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n",
@@ -849,17 +851,21 @@ static int join(struct mddev *mddev, int nodes)
849851
pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number);
850852
snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1);
851853
cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
852-
if (!cinfo->bitmap_lockres)
854+
if (!cinfo->bitmap_lockres) {
855+
ret = -ENOMEM;
853856
goto err;
857+
}
854858
if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
855859
pr_err("Failed to get bitmap lock\n");
856860
ret = -EINVAL;
857861
goto err;
858862
}
859863

860864
cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
861-
if (!cinfo->resync_lockres)
865+
if (!cinfo->resync_lockres) {
866+
ret = -ENOMEM;
862867
goto err;
868+
}
863869

864870
return 0;
865871
err:

0 commit comments

Comments
 (0)