public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] eth_receive(): Do not assume that caller always wants full packet.
@ 2009-07-14  8:08 Piotr Ziecik
  2009-07-15 15:05 ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Piotr Ziecik @ 2009-07-14  8:08 UTC (permalink / raw)
  To: u-boot

When packets arrive on the interface that are larger than the buffer
being passed to U-Boot from a standalone application, then the eth_receive()
returns -1 and leaves the packet saved. The next call to eth_receive()
will find that same packet and can fail for the exact same reason.
A typical scenario is the loader doing ARP with a buffer of 66 bytes.
The end result is that the ARP will fail and the loader panics.

This patch fixes above problem by allowing partial packet read.

Signed-off-by: Marcel Moolenaar <xcllnt@mac.com>
Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
---
 net/eth.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 3d93966..f0124f8 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -416,10 +416,7 @@ int eth_receive(volatile void *packet, int length)
 			return -1;
 	}
 
-	if (length < eth_rcv_bufs[eth_rcv_current].length)
-		return -1;
-
-	length = eth_rcv_bufs[eth_rcv_current].length;
+	length = min(length, eth_rcv_bufs[eth_rcv_current].length);
 
 	for (i = 0; i < length; i++)
 		p[i] = eth_rcv_bufs[eth_rcv_current].data[i];
-- 
1.5.2.2

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

end of thread, other threads:[~2009-07-17 20:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14  8:08 [U-Boot] [PATCH] eth_receive(): Do not assume that caller always wants full packet Piotr Ziecik
2009-07-15 15:05 ` Mike Frysinger
2009-07-16  9:51   ` Piotr Zięcik
2009-07-16 12:39     ` Wolfgang Denk
2009-07-16 13:32       ` Piotr Zięcik
2009-07-16 15:08       ` Marcel Moolenaar
2009-07-16 15:39         ` Wolfgang Denk
2009-07-16 16:42           ` Marcel Moolenaar
2009-07-17 20:11             ` Wolfgang Denk
2009-07-16 17:32   ` Ben Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox