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

nbd: error out if socket index doesn't match in nbd_handle_reply()



commit fcf3d633 ("nbd: check sock index in nbd_read_stat()") just
add error message when socket index doesn't match. Since the request
and reply must be transmitted over the same socket, it's ok to error
out in such situation.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20211101092538.1155842-1-yukuai3@huawei.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 579b5174
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -762,6 +762,8 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_device *nbd, int index,
	if (cmd->index != index) {
		dev_err(disk_to_dev(nbd->disk), "Unexpected reply %d from different sock %d (expected %d)",
			tag, index, cmd->index);
		ret = -ENOENT;
		goto out;
	}
	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",