From: Mike Frysinger Date: Mon, 17 Oct 2011 18:29:32 -0400 Subject: [U-Boot] [PATCH] ne2000: Fix broken build of three boards after CONFIG_NET_MULTI drop In-Reply-To: <201110171826.38699.vapier@gentoo.org> References: <1318788777-1679-1-git-send-email-bernhard.kaindl@gmx.net> <4E9CA6A8.6030002@gmx.net> <201110171826.38699.vapier@gentoo.org> Message-ID: <201110171829.33368.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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