From nobody Thu May 2 18:04:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550248660509945.7945419561198; Fri, 15 Feb 2019 08:37:40 -0800 (PST) Received: from localhost ([127.0.0.1]:42681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugUb-0000Xn-IA for importer@patchew.org; Fri, 15 Feb 2019 11:37:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugJR-0001TU-Bm for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gugJQ-0007Gn-EX for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:05 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:40375) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gugJN-00076y-NH; Fri, 15 Feb 2019 11:26:02 -0500 X-IronPort-AV: E=Sophos;i="5.58,373,1544486400"; d="scan'208";a="78260862" From: Paul Durrant To: , , Date: Fri, 15 Feb 2019 16:25:31 +0000 Message-ID: <20190215162533.19475-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb6 In-Reply-To: <20190215162533.19475-1-paul.durrant@citrix.com> References: <20190215162533.19475-1-paul.durrant@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PATCH 1/3] dataplane/xen-block: remove dead code 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 , Peter Maydell , Stefano Stabellini , Max Reitz , Paul Durrant , Stefan Hajnoczi , Anthony Perard Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The if() statement is clearly bogus (dead code which should have been cleaned up when grant mapping was removed). Spotted by Coverity: CID 1398635 While in the neighbourhood, add a missing 'fall through' annotation. Reported-by: Peter Maydell Signed-off-by: Paul Durrant Acked-by: Anthony PERARD --- Cc: Stefan Hajnoczi Cc: Stefano Stabellini Cc: Anthony Perard Cc: Kevin Wolf Cc: Max Reitz --- hw/block/dataplane/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index c6a15da024..f1523c5b45 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -281,10 +281,6 @@ static void xen_block_complete_aio(void *opaque, int r= et) break; case BLKIF_OP_WRITE: case BLKIF_OP_FLUSH_DISKCACHE: - if (!request->req.nr_segments) { - break; - } - break; default: break; } @@ -298,6 +294,7 @@ static void xen_block_complete_aio(void *opaque, int re= t) if (!request->req.nr_segments) { break; } + /* fall through */ case BLKIF_OP_READ: if (request->status =3D=3D BLKIF_RSP_OKAY) { block_acct_done(blk_get_stats(dataplane->blk), &request->acct); --=20 2.20.1.2.gb21ebb6 From nobody Thu May 2 18:04:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550248156205935.6697844738362; Fri, 15 Feb 2019 08:29:16 -0800 (PST) Received: from localhost ([127.0.0.1]:42519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugMR-0003HA-T4 for importer@patchew.org; Fri, 15 Feb 2019 11:29:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugJO-0001Pz-15 for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gugJN-0007BM-33 for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:01 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:40362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gugJM-000711-BS; Fri, 15 Feb 2019 11:26:00 -0500 X-IronPort-AV: E=Sophos;i="5.58,373,1544486400"; d="scan'208";a="78260850" From: Paul Durrant To: , , Date: Fri, 15 Feb 2019 16:25:32 +0000 Message-ID: <20190215162533.19475-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb6 In-Reply-To: <20190215162533.19475-1-paul.durrant@citrix.com> References: <20190215162533.19475-1-paul.durrant@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PATCH 2/3] xen-block: remove redundant assignment 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 , Peter Maydell , Stefano Stabellini , Max Reitz , Paul Durrant , Anthony Perard Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The assignment to 'p' is unnecessary as the code will either goto 'invalid' or p will get overwritten. Spotted by Coverity: CID 1398638 Reported-by: Peter Maydell Signed-off-by: Paul Durrant Acked-by: Anthony PERARD --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Kevin Wolf Cc: Max Reitz --- hw/block/xen-block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 5012af9cb6..29afe2703a 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -413,8 +413,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v,= const char *name, } =20 if (*end =3D=3D 'p') { - p =3D (char *) ++end; - if (*end =3D=3D '\0') { + if (*(++end) =3D=3D '\0') { goto invalid; } } --=20 2.20.1.2.gb21ebb6 From nobody Thu May 2 18:04:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550248800949103.43984202132526; Fri, 15 Feb 2019 08:40:00 -0800 (PST) Received: from localhost ([127.0.0.1]:42737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugWs-0002SM-0q for importer@patchew.org; Fri, 15 Feb 2019 11:39:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gugJP-0001RQ-Fe for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gugJO-0007DR-73 for qemu-devel@nongnu.org; Fri, 15 Feb 2019 11:26:03 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:40362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gugJN-000711-NT; Fri, 15 Feb 2019 11:26:02 -0500 X-IronPort-AV: E=Sophos;i="5.58,373,1544486400"; d="scan'208";a="78260871" From: Paul Durrant To: , , Date: Fri, 15 Feb 2019 16:25:33 +0000 Message-ID: <20190215162533.19475-4-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb6 In-Reply-To: <20190215162533.19475-1-paul.durrant@citrix.com> References: <20190215162533.19475-1-paul.durrant@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PATCH 3/3] xen-block: report error condition from vbd_name_to_disk() 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 , Peter Maydell , Stefano Stabellini , Max Reitz , Paul Durrant , Anthony Perard Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The function needs to make sure it is passed a valid disk name. This is easily done by making sure that the parsing loop results in a non-zero value. Spotted by Coverity: CID 1398640 Reported-by: Peter Maydell Signed-off-by: Paul Durrant Acked-by: Anthony PERARD --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Kevin Wolf Cc: Max Reitz --- hw/block/xen-block.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 29afe2703a..37a456c207 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -351,21 +351,28 @@ static void xen_block_get_vdev(Object *obj, Visitor *= v, const char *name, g_free(str); } =20 -static unsigned int vbd_name_to_disk(const char *name, const char **endp) +static int vbd_name_to_disk(const char *name, const char **endp, + unsigned long *disk) { - unsigned int disk =3D 0; + unsigned int n =3D 0; =20 while (*name !=3D '\0') { if (!g_ascii_isalpha(*name) || !g_ascii_islower(*name)) { break; } =20 - disk *=3D 26; - disk +=3D *name++ - 'a' + 1; + n *=3D 26; + n +=3D *name++ - 'a' + 1; } *endp =3D name; =20 - return disk - 1; + if (!n) { + return -1; + } + + *disk =3D n - 1; + + return 0; } =20 static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, @@ -418,7 +425,9 @@ static void xen_block_set_vdev(Object *obj, Visitor *v,= const char *name, } } } else { - vdev->disk =3D vbd_name_to_disk(p, &end); + if (vbd_name_to_disk(p, &end, &vdev->disk)) { + goto invalid; + } } =20 if (*end !=3D '\0') { --=20 2.20.1.2.gb21ebb6