From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ajay Bhargav Date: Tue, 30 Aug 2011 10:45:57 +0530 (IST) Subject: [U-Boot] [PATCH v3 1/3] net: Adds Fast Ethernet Controller driver for Armada100 In-Reply-To: <201108291539.28939.vapier@gentoo.org> Message-ID: <255679234.5372.1314681357030.JavaMail.root@ahm.einfochips.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de ----- "Mike Frysinger" wrote: > On Monday, August 29, 2011 01:39:18 Ajay Bhargav wrote: > > ----- "Mike Frysinger" wrote: > > > On Monday, August 29, 2011 01:10:49 Ajay Bhargav wrote: > > > > ----- "Mike Frysinger" wrote: > > > > > On Friday, August 26, 2011 02:36:51 Ajay Bhargav wrote: > > > > > > + darmdfec = malloc(sizeof(struct armdfec_device)); > > > > > > + if (!darmdfec) > > > > > > + goto error; > > > > > > > > > > if this first one fails, we jump to: > > > > > > +error: > > > > > > + free(darmdfec->p_aligned_txbuf); > > > > > > + free(darmdfec->p_rxbuf); > > > > > > + free(darmdfec->p_rxdesc); > > > > > > + free(darmdfec->htpr); > > > > > > > > > > looks like 4 NULL pointer derefs. so you'll need one > specific > > > > > > path > > > > > > > > for the first malloc(), but the rest are fine. > > > > > > > > so you mean like this... > > > > > > > > if(!darmdfec) > > > > > > > > goto error; > > > > > > > > ... > > > > > > > > error1: > > > > free(darmdfec->p_aligned_txbuf); > > > > free(darmdfec->p_rxbuf); > > > > free(darmdfec->p_rxdesc); > > > > free(darmdfec->htpr); > > > > > > > > error: > > > > free(darmdfec); > > > > return -1; > > > > > > that's one way of fixing it > > > > Any other better way? > > since all your buffers are known fixed (at compile time) sizes, you > could > simply inline them into the structure so you only malloc() one buffer > -mike Yes.. thats another way of coding :) I will stick to previous one.. Thanks, Ajay Bhargav