From nobody Sun Apr 28 09:11:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510450867102304.83106730268935; Sat, 11 Nov 2017 17:41:07 -0800 (PST) Received: from localhost ([::1]:47689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDhGP-00057J-Pt for importer@patchew.org; Sat, 11 Nov 2017 20:40:45 -0500 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 Received: from mx1.redhat.com ([209.132.183.28]:52886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDhFO-0000TJ-10; Sat, 11 Nov 2017 20:39:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EEC49C04AC4A; Sun, 12 Nov 2017 01:39:39 +0000 (UTC) Received: from red.redhat.com (ovpn-120-143.rdu2.redhat.com [10.10.120.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91B934A1; Sun, 12 Nov 2017 01:39:38 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Sat, 11 Nov 2017 19:39:36 -0600 Message-Id: <20171112013936.5942-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 12 Nov 2017 01:39:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.11] nbd: Don't crash when server reports NBD_CMD_READ failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , vsementsov@virtuozzo.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Vladimir Sementsov-Ogievskiy --- 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 *opaqu= e) while (!s->quit) { assert(s->reply.handle =3D=3D 0); ret =3D nbd_receive_reply(s->ioc, &s->reply, &local_err); - if (ret < 0) { + if (local_err) { error_report_err(local_err); } if (ret <=3D 0) { @@ -681,7 +681,7 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t= offset, ret =3D nbd_co_receive_cmdread_reply(client, request.handle, offset, q= iov, &local_err); - if (ret < 0) { + if (local_err) { error_report_err(local_err); } return ret; --=20 2.13.6