[U-Boot] [PATCH v3 1/3] net: Adds Fast Ethernet Controller driver for Armada100

Marek Vasut marek.vasut at gmail.com
Mon Aug 29 12:12:55 CEST 2011


On Monday, August 29, 2011 07:39:18 AM Ajay Bhargav wrote:
> ----- "Mike Frysinger" <vapier at gentoo.org> wrote:
> > On Monday, August 29, 2011 01:10:49 Ajay Bhargav wrote:
> > > ----- "Mike Frysinger" <vapier at gentoo.org> 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
> > -mike
> 
> Any other better way?

I'd love to be enlightened on this topic too ...

> 
> --Ajay
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list