netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
@ 2015-05-22 11:15 Bjørn Mork
  2015-05-22 17:22 ` Ben Hutchings
       [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Bjørn Mork @ 2015-05-22 11:15 UTC (permalink / raw)
  To: netdev
  Cc: Florian Bruhin, linux-usb, Oliver Neukum, Bjørn Mork,
	Ben Hutchings

The tx_curr_frame_payload field is u32. When we try to calculate a
small negative delta based on it, we end up with a positive integer
close to 2^32 instead.  So the tx_bytes pointer increases by about
2^32 for every transmitted frame.

Fix by calculating the delta as a signed long.

Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Reported-by: Florian Bruhin <me@the-compiler.org>
Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index c3e4da9e79ca..8067b8fbb0ee 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1182,7 +1182,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
 	 * payload data instead.
 	 */
 	usbnet_set_skb_tx_stats(skb_out, n,
-				ctx->tx_curr_frame_payload - skb_out->len);
+				(long)ctx->tx_curr_frame_payload - skb_out->len);
 
 	return skb_out;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-23  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 11:15 [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics Bjørn Mork
2015-05-22 17:22 ` Ben Hutchings
2015-05-22 18:48   ` Bjørn Mork
     [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2015-05-22 18:34   ` David Miller
     [not found]     ` <20150522.143421.442426385899149301.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-05-23  9:27       ` Florian Bruhin

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).