Re: [PATCH] [STACK] >3k call path in ide

From: Jörn Engel
Date: Wed Jun 16 2004 - 04:49:20 EST


On Wed, 16 June 2004 09:11:11 +0200, Florian Schirmer wrote:
>
> > failed:
> > ide_release(link);
> > link->state &= ~DEV_CONFIG_PENDING;
> >
> > + /* memory allocation errors */
> > +err_cisparse:
> > + kfree(cfginfo);
> > +err_cfginfo:
> > + kfree(def_cte);
> > +err_def_cte:
> > + kfree(tbuf);
> > +err_tbuf:
> > + printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n");
> > + goto failed;
> > } /* ide_config */
>
> Huh? This will either leak memory (non alloc error case) or deadlock (mem
> alloc error case). I'm missing something?

Leak memory. I also tend to depend on the fact that kfree(NULL) works
just fine:

err_kfree:
kfree(cfginfo);
kfree(def_cte);
kfree(tbuf);
printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n");
goto failed;

Makes the error path a little simpler.

Jörn

--
The strong give up and move away, while the weak give up and stay.
-- unknown
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/