[U-Boot] [PATCH 22/28] net: Fix net buffer initialization
Joe Hershberger
joe.hershberger at gmail.com
Fri Feb 10 21:34:05 CET 2012
Hi Mike,
On Fri, Feb 3, 2012 at 6:37 AM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Thursday 19 January 2012 19:53:25 Joe Hershberger wrote:
>> @@ -627,6 +639,12 @@ NetSendUDPPacket
>>
>> + /* make sure the NetTxPacket is initialized (NetInit() was called) */
>> + if (NetTxPacket == NULL) {
>> + puts("*** ERROR: NetTxPacket buffer pointer is NULL!\n");
>> + return -1;
>> + }
>
> why check here only (udp) ? and why check at all ? this should be an
> assert() in the comment netsendpacket entry point ...
This is specifically needed here because the NetSendUDPPacket()
function expects to use the NetTxPacket as a buffer and will write
header information into it. The NetSendPacket() function takes the
packet buffer itself as a parameter, so it isn't expecting anything as
a side-band precondition to avoid crashing. I specifically added the
check because the failure to initialize NetTxPacket in all code paths
caused problems. It is easy to run into this if someone were to add a
new thing that can send a packet. I will change it to an assert.
-Joe
More information about the U-Boot
mailing list