Commit fcf3d633 authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe
Browse files

nbd: check sock index in nbd_read_stat()



The sock that clent send request in nbd_send_cmd() and receive reply
in nbd_read_stat() should be the same.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20210916093350.1410403-4-yukuai3@huawei.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 07175cb1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -751,6 +751,10 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
		ret = -ENOENT;
		goto out;
	}
	if (cmd->index != index) {
		dev_err(disk_to_dev(nbd->disk), "Unexpected reply %d from different sock %d (expected %d)",
			tag, index, cmd->index);
	}
	if (cmd->cmd_cookie != nbd_handle_to_cookie(handle)) {
		dev_err(disk_to_dev(nbd->disk), "Double reply on req %p, cmd_cookie %u, handle cookie %u\n",
			req, cmd->cmd_cookie, nbd_handle_to_cookie(handle));