diff mbox series

net: ethernet: dec: tulip: Fix length mask in receive length calculation

Message ID 20200204230118.7877-1-mdf@kernel.org (mailing list archive)
State Awaiting Upstream
Headers show
Series net: ethernet: dec: tulip: Fix length mask in receive length calculation | expand

Commit Message

Moritz Fischer Feb. 4, 2020, 11:01 p.m. UTC
The receive frame length calculation uses a wrong mask to calculate the
length of the received frames.

Per spec table 4-1 the length is contained in the FL (Frame Length)
field in bits 30:16.

This didn't show up as an issue so far since frames were limited to
1500 bytes which falls within the 11 bit window.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de2104x.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

David Miller Feb. 5, 2020, 1:21 p.m. UTC | #1
From: Moritz Fischer <mdf@kernel.org>
Date: Tue,  4 Feb 2020 15:01:18 -0800

> The receive frame length calculation uses a wrong mask to calculate the
> length of the received frames.
> 
> Per spec table 4-1 the length is contained in the FL (Frame Length)
> field in bits 30:16.
> 
> This didn't show up as an issue so far since frames were limited to
> 1500 bytes which falls within the 11 bit window.
> 
> Signed-off-by: Moritz Fischer <mdf@kernel.org>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index d305d1b24b0a..42b798a3fad4 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -417,7 +417,10 @@  static void de_rx (struct de_private *de)
 		if (status & DescOwn)
 			break;
 
-		len = ((status >> 16) & 0x7ff) - 4;
+		/* the length is actually a 15 bit value here according
+		 * to Table 4-1 in the DE2104x spec so mask is 0x7fff
+		 */
+		len = ((status >> 16) & 0x7fff) - 4;
 		mapping = de->rx_skb[rx_tail].mapping;
 
 		if (unlikely(drop)) {