From patchwork Fri Nov 3 08:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10039693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF8CE6032D for ; Fri, 3 Nov 2017 08:44:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9A7828DBB for ; Fri, 3 Nov 2017 08:44:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC90128E12; Fri, 3 Nov 2017 08:44:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4648D28DBB for ; Fri, 3 Nov 2017 08:44:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAXYH-00071T-3u; Fri, 03 Nov 2017 08:42:09 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAXYG-00071N-2D for xen-devel@lists.xenproject.org; Fri, 03 Nov 2017 08:42:08 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id FE/21-21967-FDB2CF95; Fri, 03 Nov 2017 08:42:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42KJ3htZoHtP+0+ kQVuXpsX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvGyuZ29YCdnxYOlZ9gaGCdwdDFycggJNDJJ 7PjnBWKzCWhL7H/WwgZiiwgUS7R37GUEsZkFnCT+fO1gBbGFBVwlJpy/wwxiswioSjTteANWw ytgK3Fn/Q52EFtCQF7i3IPbzBBxQYmTM5+wdDFyAM3RlFi/Sx9ipLxE89bZzBMYuWchqZqFUD ULSdUCRuZVjBrFqUVlqUW6RhZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBAVL PwMC4g7Fvld8hRkkOJiVR3rsbf0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBdrvUnUkiwKDU9 tSItMwcYqjBpCQ4eJRHeRJA0b3FBYm5xZjpE6hSjJcexTZf/MHF03LwLJJ/NfN3ALMSSl5+XK iXOux2kQQCkIaM0D24cLJ4uMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmzQOZwpOZVwK39R XQQUxAB83mADuoJBEhJdXAOHUt90z5zFWHHeWDXk40cl/01+y6o3b+vKZH3Jm7s357HzoyLeh D56WZVtfWSezrLMsUvPTwwsmcByyr7FOYy1ZY3+fd9C3C69e63xe8yj7dSde/u75p2vdF38w+ 8c3XPO7leNEl9fDGd1OFt8f7zLvtHBls6aEb41b6IvvFrdCAsEssLrNWKCmxFGckGmoxFxUnA gDTpM1QogIAAA== X-Env-Sender: colin.king@canonical.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1509698526!110051521!1 X-Originating-IP: [91.189.89.112] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49034 invoked from network); 3 Nov 2017 08:42:06 -0000 Received: from youngberry.canonical.com (HELO youngberry.canonical.com) (91.189.89.112) by server-9.tower-206.messagelabs.com with AES256-SHA encrypted SMTP; 3 Nov 2017 08:42:06 -0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1eAXYA-0007Sp-JQ; Fri, 03 Nov 2017 08:42:02 +0000 From: Colin King To: Boris Ostrovsky , Juergen Gross , xen-devel@lists.xenproject.org Date: Fri, 3 Nov 2017 08:42:02 +0000 Message-Id: <20171103084202.27790-1-colin.king@canonical.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH] xen/pvcalls: fix unsigned less than zero error check X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King The check on bedata->ref is never true because ref is an unsigned integer. Fix this by assigning signed int ret to the return of the call to gnttab_claim_grant_reference so the -ve return can be checked. Detected by CoverityScan, CID#1460358 ("Unsigned compared against 0") Fixes: 219681909913 ("xen/pvcalls: connect to the backend") Signed-off-by: Colin Ian King Reviewed-by: Juergen Gross --- drivers/xen/pvcalls-front.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index 0c1ec6894cc4..de8a470351a5 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -1186,11 +1186,10 @@ static int pvcalls_front_probe(struct xenbus_device *dev, ret = gnttab_alloc_grant_references(1, &gref_head); if (ret < 0) goto error; - bedata->ref = gnttab_claim_grant_reference(&gref_head); - if (bedata->ref < 0) { - ret = bedata->ref; + ret = gnttab_claim_grant_reference(&gref_head); + if (ret < 0) goto error; - } + bedata->ref = ret; gnttab_grant_foreign_access_ref(bedata->ref, dev->otherend_id, virt_to_gfn((void *)sring), 0);