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: 623437 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3r8myG4RWDz9vKg for ; Wed, 18 May 2016 18:07:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752371AbcERIHB (ORCPT ); Wed, 18 May 2016 04:07:01 -0400 Received: from smtp.citrix.com ([66.165.176.89]:33882 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752256AbcERIG4 (ORCPT ); Wed, 18 May 2016 04:06:56 -0400 X-IronPort-AV: E=Sophos;i="5.26,328,1459814400"; d="scan'208";a="354970244" From: Paul Durrant To: , CC: Paul Durrant , Wei Liu Subject: [PATCH net-next] xen-netback: correct length checks on hash copy_ops 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 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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)