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

!1031 nbd: get config_lock before sock_shutdown

parents d7de31a5 2b54b997
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1406,11 +1406,16 @@ 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);
	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))