netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Mitch Williams <mitch.a.williams@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Andrew Bowers <andrewx.bowers@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 02/11] iavf: use signed variable
Date: Mon, 17 Jun 2019 16:33:27 -0700	[thread overview]
Message-ID: <20190617233336.18119-3-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20190617233336.18119-1-jeffrey.t.kirsher@intel.com>

From: Mitch Williams <mitch.a.williams@intel.com>

The counter variable in iavf_clean_tx_irq starts out negative and climbs
to 0. So allocating it as u16 is actually a really bad idea that just
happens to work because the value underflows and overflows consistently
on most architectures.

Replace the u16 with an int so signed math works as expected.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
index 6d43cbe29c49..d28b57937245 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
@@ -190,7 +190,7 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi)
 static bool iavf_clean_tx_irq(struct iavf_vsi *vsi,
 			      struct iavf_ring *tx_ring, int napi_budget)
 {
-	u16 i = tx_ring->next_to_clean;
+	int i = tx_ring->next_to_clean;
 	struct iavf_tx_buffer *tx_buf;
 	struct iavf_tx_desc *tx_desc;
 	unsigned int total_bytes = 0, total_packets = 0;
-- 
2.21.0


  parent reply	other threads:[~2019-06-17 23:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 23:33 [net-next 00/11][pull request] Intel Wired LAN Driver Updates 2019-06-17 Jeff Kirsher
2019-06-17 23:33 ` [net-next 01/11] iavf: Create VLAN tag elements starting from the first element Jeff Kirsher
2019-06-17 23:33 ` Jeff Kirsher [this message]
2019-06-17 23:33 ` [net-next 03/11] iavf: wait longer for close to complete Jeff Kirsher
2019-06-17 23:33 ` [net-next 04/11] iavf: Change GFP_KERNEL to GFP_ATOMIC in kzalloc() Jeff Kirsher
2019-06-17 23:33 ` [net-next 05/11] iavf: Fix the math for valid length for ADq enable Jeff Kirsher
2019-06-17 23:33 ` [net-next 06/11] iavf: Move commands processing to the separate function Jeff Kirsher
2019-06-17 23:33 ` [net-next 07/11] iavf: Remove timer for work triggering, use delaying work instead Jeff Kirsher
2019-06-17 23:33 ` [net-next 08/11] iavf: Refactor the watchdog state machine Jeff Kirsher
2019-06-17 23:33 ` [net-next 09/11] iavf: Refactor init " Jeff Kirsher
2019-06-17 23:33 ` [net-next 10/11] iavf: add call to iavf_[add|del]_cloud_filter Jeff Kirsher
2019-06-17 23:33 ` [net-next 11/11] iavf: allow null RX descriptors Jeff Kirsher
2019-06-18 16:44 ` [net-next 00/11][pull request] Intel Wired LAN Driver Updates 2019-06-17 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=20190617233336.18119-3-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=andrewx.bowers@intel.com \
    --cc=davem@davemloft.net \
    --cc=mitch.a.williams@intel.com \
    --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;
as well as URLs for NNTP newsgroup(s).