From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDhFT-0004jj-BC for qemu-devel@nongnu.org; Sat, 11 Nov 2017 20:39:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDhFS-0000VD-Jj for qemu-devel@nongnu.org; Sat, 11 Nov 2017 20:39:47 -0500 From: Eric Blake Date: Sat, 11 Nov 2017 19:39:36 -0600 Message-Id: <20171112013936.5942-1-eblake@redhat.com> Subject: [Qemu-devel] [PATCH for-2.11] nbd: Don't crash when server reports NBD_CMD_READ failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, vsementsov@virtuozzo.com, Paolo Bonzini , Kevin Wolf , Max Reitz If a server fails a read, for example with EIO, but the connection is still live, then we would crash trying to print a non-existent error message. Bug introduced in commit f140e300. Signed-off-by: Eric Blake --- block/nbd-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index b44d4d4a01..5f3375a970 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -78,7 +78,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque) while (!s->quit) { assert(s->reply.handle == 0); ret = nbd_receive_reply(s->ioc, &s->reply, &local_err); - if (ret < 0) { + if (local_err) { error_report_err(local_err); } if (ret <= 0) { @@ -681,7 +681,7 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, ret = nbd_co_receive_cmdread_reply(client, request.handle, offset, qiov, &local_err); - if (ret < 0) { + if (local_err) { error_report_err(local_err); } return ret; -- 2.13.6