From patchwork Wed May 18 07:53:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9116711 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 50059BF29F for ; Wed, 18 May 2016 08:09:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3ADE20138 for ; Wed, 18 May 2016 08:09:33 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D39AE20123 for ; Wed, 18 May 2016 08:09:32 +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 1b2wVa-00048U-Kg; Wed, 18 May 2016 08:07:10 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2wVZ-00048O-Oi for xen-devel@lists.xenproject.org; Wed, 18 May 2016 08:07:09 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 2A/A0-07120-DA22C375; Wed, 18 May 2016 08:07:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHRDpO4aJZt wgx/7jSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxph+4zFczirjj1+z1bA+Nezi5GTg4JAX+J Ty9mMILYbAI6ElOfXmIFsUUE7CTO9bwHsjk4mAU8JXpumYOEhQV8JbouvwMrZxFQlVj8cgILi M0r4C5xpfUHE8RIOYnzx38yg9hCAioS66fOYoOoEZQ4OfMJWD2zgITEwRcvmCHquSVun57KPI GRZxaSsllIyhYwMq1iVC9OLSpLLdI11ksqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93 ECAwQBiDYwdjxz+kQoyQHk5Io71Z5m3AhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErzVikA5waLU 9NSKtMwcYKjCpCU4eJREeGVA0rzFBYm5xZnpEKlTjIpS4ryBIAkBkERGaR5cGyw+LjHKSgnzM gIdIsRTkFqUm1mCKv+KUZyDUUmYNwZkCk9mXgnc9FdAi5mAFt8SA1tckoiQkmpgnHOudNN8fS 8v5bv715wrTLkQNvPrnevpgnqeixO2+3eezz/mn/4yQ36mqnzIROUjWwQF3XKlr34t8DJvDdn EumzfdgOXT7O+Ptog+02zWVO87vf12M1T5j+9m5WdohyUOUP1dGfoudUvstQenbmeM3XxRMeL H7mKkizP++qFfjd8+IJ57d2OP0osxRmJhlrMRcWJAPvwx0KKAgAA X-Env-Sender: prvs=93930de3f=Paul.Durrant@citrix.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1463558827!14644137!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46772 invoked from network); 18 May 2016 08:07:08 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-8.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 18 May 2016 08:07:08 -0000 X-IronPort-AV: E=Sophos;i="5.26,328,1459814400"; d="scan'208";a="354970244" From: Paul Durrant To: , Date: Wed, 18 May 2016 08:53:01 +0100 Message-ID: <1463557981-17294-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Paul Durrant , Wei Liu Subject: [Xen-devel] [PATCH net-next] xen-netback: correct length checks on hash copy_ops 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The length checks on the grant table copy_ops for setting hash key and hash mapping are checking the local 'len' value which is correct in the case of the former but not the latter. This was picked up by static analysis checks. This patch replaces checks of 'len' with 'copy_op.len' in both cases to correct the incorrect check, keep the two checks consistent, and to make it clear what the checks are for. Signed-off-by: Paul Durrant Reported-by: Dan Carpenter Cc: Wei Liu Acked-by: Wei Liu --- drivers/net/xen-netback/hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c index 392e392..fb87cb3 100644 --- a/drivers/net/xen-netback/hash.c +++ b/drivers/net/xen-netback/hash.c @@ -311,7 +311,7 @@ u32 xenvif_set_hash_key(struct xenvif *vif, u32 gref, u32 len) if (len > XEN_NETBK_MAX_HASH_KEY_SIZE) return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; - if (len != 0) { + if (copy_op.len != 0) { gnttab_batch_copy(©_op, 1); if (copy_op.status != GNTST_okay) @@ -359,7 +359,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len, if (mapping[off++] >= vif->num_queues) return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; - if (len != 0) { + if (copy_op.len != 0) { gnttab_batch_copy(©_op, 1); if (copy_op.status != GNTST_okay)