From: Guoqing Jiang Date: Tue, 16 May 2017 06:01:25 +0000 (+0800) Subject: md-cluster: fix potential lock issue in add_new_disk X-Git-Tag: v4.1.52~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8e2096553ae1f1ec689d8444994fdea7ecf3b9b;p=thirdparty%2Fkernel%2Fstable.git md-cluster: fix potential lock issue in add_new_disk [ Upstream commit 2dffdc0724004f38f5e39907747b53e4b0d80e59 ] The add_new_disk returns with communication locked if __sendmsg returns failure, fix it with call unlock_comm before return. Reported-by: Dan Carpenter CC: Goldwyn Rodrigues Signed-off-by: Guoqing Jiang Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin --- diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 4eb5cb18f98da..f490382173b67 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -850,8 +850,10 @@ static int add_new_disk_start(struct mddev *mddev, struct md_rdev *rdev) cmsg.raid_slot = rdev->desc_nr; lock_comm(cinfo); ret = __sendmsg(cinfo, &cmsg); - if (ret) + if (ret) { + unlock_comm(cinfo); return ret; + } cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE; ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX); cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE;