Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2174907yba; Mon, 6 May 2019 00:43:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVIZzhx8jUHbMREzJALqs9k0CGRVEDrlnW2nam7MLSfgXCeACnDY9rcQpQf9RIMd8gfZ2P X-Received: by 2002:a63:b1d:: with SMTP id 29mr30553851pgl.103.1557128594172; Mon, 06 May 2019 00:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557128594; cv=none; d=google.com; s=arc-20160816; b=hQkohZIdHdHOYld49BZFDd/mBkjEYF5elvNKBs//FLLXC4L93fzmfbdXe7yyndKwzu tjfLjWGw6Wis3BNFhXpQIKzrLl/I5ER3p7lAnFDnOG1Ta9MLfOToivBkNsY4nyyb+Z+f C+rKXqx4rYrWZj2B7uBg4a+UYQOINl4CwL7di+Ygq2OosChrMibGDPGMC4T6OSZWVB1x sxzEvMMGyX5dIFwfdKhVHpglbwde6wCPahLE5n+yK6XbKOBtysK4m3tvZFYdH6hunzkL NsqyHB8eP0eno7xpLfS4DZ/Mb/GrmTpOtdzQRvz7ZqutVFrFq1Gn8OQ+nDY0qmxGqfDu 1ICg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Hsz9j7FIho0zz3uHM1FE+gpro2H2SMPFf1U8+9CImkM=; b=G252G7qk4NBOwRn5MMRMwYJfmMitiY+aBrHGu46IOtCpXbmuDNKALGFBY1ANVOn7hx zkBeN3pw/C3o+juH/Th3zdWj+ZbJGVy4WEqZ6OKH7D2v58k/qL0v7ExOPbBCuL5bejC5 jK22+fk8IKH4AtppLH83WFP1bNNzthdpp/rKZGIHn4fKStle0unVmDIqxKtE55PpGgB2 7LPWQq5QU5zYYoQMzlti5TC1tLtdxGTSCTlzQCuilmCUg0yTKrn1zhwRd7/p5BS1CYQr YlX5RadKasbFcMXkNc44yOqX6upEAc8Cfc4hRrnINNFMmImW5ERlRXOPPb8YFUU2N4/9 xdLg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m186si15459853pfb.96.2019.05.06.00.42.58; Mon, 06 May 2019 00:43:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbfEFHmE (ORCPT + 99 others); Mon, 6 May 2019 03:42:04 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:51185 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbfEFHmE (ORCPT ); Mon, 6 May 2019 03:42:04 -0400 X-Originating-IP: 90.88.149.145 Received: from bootlin.com (aaubervilliers-681-1-29-145.w90-88.abo.wanadoo.fr [90.88.149.145]) (Authenticated sender: maxime.chevallier@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 2A5101BF215; Mon, 6 May 2019 07:42:01 +0000 (UTC) Date: Mon, 6 May 2019 09:42:00 +0200 From: Maxime Chevallier To: Colin King Cc: "David S . Miller" , Antoine Tenart , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable Message-ID: <20190506094200.580ddaf2@bootlin.com> In-Reply-To: <20190505213814.4220-1-colin.king@canonical.com> References: <20190505213814.4220-1-colin.king@canonical.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Colin, On Sun, 5 May 2019 22:38:14 +0100 Colin King wrote: >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]; > Thanks for the fix, my bad. Reviewed-by: Maxime Chevallier Maxime