[PATCH] net: emaclite: fix possible underflow bug

Tianrui Wei tianrui-wei at outlook.com
Tue Jul 13 14:01:53 CEST 2021


This commit fixes a corner case when length < first_read. which would
cause the last argument of xemaclite_alignedread to be a very large
unsigned integer.

Signed-off-by: Tianrui Wei <tianrui-wei at outlook.com>
---
 drivers/net/xilinx_emaclite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 43fc36dc6a..3b8f0f4678 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -526,7 +526,7 @@ try_again:
 	}
 
 	/* Read the rest of the packet which is longer then first read */
-	if (length != first_read)
+	if (length >= first_read)
 		xemaclite_alignedread(addr + first_read,
 				      etherrxbuff + first_read,
 				      length - first_read);
-- 
2.32.0



More information about the U-Boot mailing list