Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

md-cluster: fix potential lock issue in add_new_disk

The add_new_disk returns with communication locked if
__sendmsg returns failure, fix it with call unlock_comm
before return.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
CC: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>

authored by

Guoqing Jiang and committed by
Shaohua Li
2dffdc07 08332893

+3 -1
+3 -1
drivers/md/md-cluster.c
··· 1311 1311 cmsg.raid_slot = cpu_to_le32(rdev->desc_nr); 1312 1312 lock_comm(cinfo, 1); 1313 1313 ret = __sendmsg(cinfo, &cmsg); 1314 - if (ret) 1314 + if (ret) { 1315 + unlock_comm(cinfo); 1315 1316 return ret; 1317 + } 1316 1318 cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE; 1317 1319 ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX); 1318 1320 cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE;