From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbdFDX6Z (ORCPT ); Sun, 4 Jun 2017 19:58:25 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:52606 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbdFDX6S (ORCPT ); Sun, 4 Jun 2017 19:58:18 -0400 Date: Sun, 04 Jun 2017 19:58:15 -0400 (EDT) Message-Id: <20170604.195815.1578427347580474114.davem@davemloft.net> To: colin.king@canonical.com Cc: peppe.cavallaro@st.com, alexandre.torgue@st.com, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value From: David Miller In-Reply-To: <20170602145827.21151-1-colin.king@canonical.com> References: <20170602145827.21151-1-colin.king@canonical.com> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sun, 04 Jun 2017 16:16:39 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin King Date: Fri, 2 Jun 2017 15:58:27 +0100 > From: Colin Ian King > > The current comparison of entry < 0 will never be true since entry is an > unsigned integer. Cast entry to an int to ensure -ve error return values > from the call to jumbo_frm are correctly being caught. > > Detected by CoverityScan, CID#1238760 ("Macro compares unsigned to 0") > > Signed-off-by: Colin Ian King Like others have suggested, probably making 'entry' signed is a better fix. I was initially worried that STMMAC_GET_ENTRY() might become more expensive if it was implemented using '%' but it is using 'and' masking instead which doesn't have that kind of problem.