[RESEND PATCH v1] net: emaclite: fix underflow bug

Tianrui Wei tianrui-wei at outlook.com
Mon Jan 10 14:46:22 CET 2022


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, resulting in an underflow

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



More information about the U-Boot mailing list