[U-Boot] [PATCH] ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop

Mike Frysinger vapier at gentoo.org
Tue Oct 18 00:29:32 CEST 2011


On Monday 17 October 2011 18:26:38 Mike Frysinger wrote:
> On Monday 17 October 2011 18:05:28 Bernhard Kaindl wrote:
> > >> +	dev = calloc(sizeof(*dev), 1);
> > >> +	pbuf = malloc(NE2000_RX_BUFFER_SIZE);
> > >> +	if (dev == NULL || pbuf == NULL)
> > >> +		return -1;
> > > 
> > > if dev worked but pbuf failed, this leaks memory
> > 
> > If malloc fails here, either CONFIG_SYS_MALLOC_LEN is to small or malloc
> > is broken. Three Ethernet drivers call hang() in this case, which is
> > probably best in explaining to the developer who broke it.
> > I can replace that with "goto error" and give an error message on it
> > like the other recently merged drivers do in this init situation.
> 
> i know there's inconsistency here with some drivers, but the current "best
> practices" is to not leak and return 0.

meh, for now, keep the -1.  but don't leak.  i'll review the drivers and 
update the documentation.
-mike


More information about the U-Boot mailing list