Unverified Commit f384ae3d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1018 [sync] PR-944: nbd: get config_lock before sock_shutdown

parents d3394d89 7c7d2b75
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1406,13 +1406,18 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
	mutex_unlock(&nbd->config_lock);
	ret = wait_event_interruptible(config->recv_wq,
					 atomic_read(&config->recv_threads) == 0);

	/*
	 * recv_work in flush_workqueue will not get this lock, because nbd_open
	 * will hold nbd->config_refs
	 */
	mutex_lock(&nbd->config_lock);
	if (ret) {
		sock_shutdown(nbd);
		nbd_clear_que(nbd);
	}

	flush_workqueue(nbd->recv_workq);
	mutex_lock(&nbd->config_lock);
	nbd_bdev_reset(bdev);
	/* user requested, ignore socket errors */
	if (test_bit(NBD_RT_DISCONNECT_REQUESTED, &config->runtime_flags))