Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1805963yba; Sun, 5 May 2019 14:39:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXqvw4WPl6YXm1yC4f1ONlReXi6/9sGid79STPE8bfrSYz/VWAA/QwosXsMMinAN6D/2wM X-Received: by 2002:a63:fb4d:: with SMTP id w13mr27970818pgj.397.1557092379504; Sun, 05 May 2019 14:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557092379; cv=none; d=google.com; s=arc-20160816; b=lP0Txp4pyB/GJ42ZP2iPmoznH+1fxy/qsEHPBr0US9/erQYGd9vF7Id1any/Yn6mES THmXNnjq5oBoxLSr9+qnC/DiR6qr7OaweY1MN7uh9Xvc7vMcq51wSU3uJ5WDajkke4ql 0eJ5RtrivoF27sHYvBtWW5nFYWDIz1MSg4+q5GcXtV9QnRgOS+DphhCn59xwkQiTEnU5 KBDEvPXHEyA164S4P6kG+knFXh7mQydYXKsLY1XlYdQ68OpHsh3UVZGQTXFk8z7ggkUn 2y5qhOmbFe+jw4gvUw6B4Jym5o4G44e3a7nynmLD86s7tqnfWMLZmmVVSXSX4o7nZYJz azAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NloxiNL9SRb0at0cDv+9PNMMrJ2zR5NekEWqx2Spuk4=; b=cYlT3DqhxhvhmvE05Y7P065QxYBmnFyIhVlnIH7aLt/aogFciSXpXiGTX9Mf9WVCaz h0lYWl1D/063JJOhg6NgOeiq61OMo+69aLhuEw3hAlvPVfdr+fv/2N8rjbJrusFfql7/ PVfZnsk58rGhKlErx4Yqwd1u50gIPfk/H8WZqJ03nXaeuZ2kAQT/Yz+sR4ajwRdxfmMF 4LT2pcFjp/P8uvcysn3x0+Dej6pwHBdQII19+ohYtuaYGbFKaeMg2sJvAvIIfsFJkBU4 qbDpJac7kKvAP+aXpXRXx70oVLJzAu3ekZoyH9lqRQc1j6dGEplFupV+LhETNT3hPHhk Hhaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn13si11553701plb.377.2019.05.05.14.39.23; Sun, 05 May 2019 14:39:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727896AbfEEViR (ORCPT + 99 others); Sun, 5 May 2019 17:38:17 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56681 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbfEEViR (ORCPT ); Sun, 5 May 2019 17:38:17 -0400 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 1hNOpq-0008GD-Hz; Sun, 05 May 2019 21:38:14 +0000 From: Colin King To: "David S . Miller" , Maxime Chevallier , Antoine Tenart , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable Date: Sun, 5 May 2019 22:38:14 +0100 Message-Id: <20190505213814.4220-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The signed return from the call to mvpp2_cls_c2_port_flow_index is being assigned to the u32 variable c2.index and then checked for a negative error condition which is always going to be false. Fix this by assigning the return to the int variable index and checking this instead. Addresses-Coverity: ("Unsigned compared against 0") Fixes: 90b509b39ac9 ("net: mvpp2: cls: Add Classification offload support") Signed-off-by: Colin Ian King --- drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c index 4989fb13244f..c10bc257f571 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c @@ -1029,12 +1029,14 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port, struct flow_action_entry *act; struct mvpp2_cls_c2_entry c2; u8 qh, ql, pmap; + int index; memset(&c2, 0, sizeof(c2)); - c2.index = mvpp2_cls_c2_port_flow_index(port, rule->loc); - if (c2.index < 0) + index = mvpp2_cls_c2_port_flow_index(port, rule->loc); + if (index < 0) return -EINVAL; + c2.index = index; act = &rule->flow->action.entries[0]; -- 2.20.1