Netdev List
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Bruce Allan <bruce.w.allan@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>,
	Andrew Bowers <andrewx.bowers@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 08/16] ice: fix numeric overflow warning
Date: Mon, 25 Feb 2019 10:42:58 -0800	[thread overview]
Message-ID: <20190225184306.13505-9-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20190225184306.13505-1-jeffrey.t.kirsher@intel.com>

From: Bruce Allan <bruce.w.allan@intel.com>

When compiling and analyzing the driver on newer kernels, a static
analyzer warns about the following "numeric overflow" issues:

  "The result of expression: 'budget-1' generates 4-byte type while casting
   to a bigger size of 8-byte".

  "The result of expression: '*words-words_read' generates 4-byte type
   while casting to a bigger size of 8-byte".

Fix them both.

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_nvm.c  | 7 ++++---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c
index ce64cecdae9c..413fdbbcc4d0 100644
--- a/drivers/net/ethernet/intel/ice/ice_nvm.c
+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c
@@ -152,9 +152,10 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
 		 */
 		off_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS;
 		read_size = off_w ?
-			min(*words,
-			    (u16)(ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
-			min((*words - words_read), ICE_SR_SECTOR_SIZE_IN_WORDS);
+			min_t(u16, *words,
+			      (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
+			min_t(u16, (*words - words_read),
+			      ICE_SR_SECTOR_SIZE_IN_WORDS);
 
 		/* Check if this is last command, if so set proper flag */
 		if ((words_read + read_size) >= *words)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 67d129bfe489..c289d97f477d 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -1169,7 +1169,7 @@ int ice_napi_poll(struct napi_struct *napi, int budget)
 		if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags))
 			ice_update_ena_itr(vsi, q_vector);
 
-	return min(work_done, budget - 1);
+	return min_t(int, work_done, budget - 1);
 }
 
 /* helper function for building cmd/type/offset */
-- 
2.20.1


  parent reply	other threads:[~2019-02-25 18:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 18:42 [net-next 00/16][pull request] 100GbE Intel Wired LAN Driver Updates 2019-02-22 Jeff Kirsher
2019-02-25 18:42 ` [net-next 01/16] ice: Mark extack argument as __always_unused Jeff Kirsher
2019-02-26  0:36   ` Stephen Hemminger
2019-02-25 18:42 ` [net-next 02/16] ice: Fix the calculation of ICE_MAX_MTU Jeff Kirsher
2019-02-25 18:42 ` [net-next 03/16] ice: Fix added in VSI supported nodes calc Jeff Kirsher
2019-02-25 18:42 ` [net-next 04/16] ice: sizeof(<type>) should be avoided Jeff Kirsher
2019-02-25 18:42 ` [net-next 05/16] ice: fix stack hogs from struct ice_vsi_ctx structures Jeff Kirsher
2019-02-25 18:42 ` [net-next 06/16] ice: fix ice_remove_rule_internal vsi_list handling Jeff Kirsher
2019-02-25 18:42 ` [net-next 07/16] ice: fix issue where host reboots on unload when iommu=on Jeff Kirsher
2019-02-25 18:42 ` Jeff Kirsher [this message]
2019-02-25 18:42 ` [net-next 09/16] ice: only use the VF for ICE_VSI_VF in ice_vsi_release Jeff Kirsher
2019-02-25 18:43 ` [net-next 10/16] ice: don't spam VFs with link messages Jeff Kirsher
2019-02-25 18:43 ` [net-next 11/16] ice: clear VF ARQLEN register on reset Jeff Kirsher
2019-02-25 18:43 ` [net-next 12/16] ice: flush Tx pipe on disable queue timeout Jeff Kirsher
2019-02-25 18:43 ` [net-next 13/16] ice: check for a leaf node presence Jeff Kirsher
2019-02-25 18:43 ` [net-next 14/16] ice: use absolute vector ID for VFs Jeff Kirsher
2019-02-25 18:43 ` [net-next 15/16] ice: Fix for FC get rx/tx pause params Jeff Kirsher
2019-02-25 18:43 ` [net-next 16/16] ice: fix overlong string, update stats output Jeff Kirsher
2019-02-25 22:14 ` [net-next 00/16][pull request] 100GbE Intel Wired LAN Driver Updates 2019-02-22 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190225184306.13505-9-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=andrewx.bowers@intel.com \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=bruce.w.allan@intel.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox