[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20061023040018.28823.qmail@web55602.mail.re4.yahoo.com>
Date: Sun, 22 Oct 2006 21:00:17 -0700 (PDT)
From: Amit Choudhary <amit2030@...oo.com>
To: Roland Dreier <rdreier@...co.com>
Cc: Jan Engelhardt <jengelh@...ux01.gwdg.de>,
Pekka Enberg <penberg@...helsinki.fi>,
linux-kernel@...r.kernel.org
Subject: Re: Hopefully, kmalloc() will always succeed, but if it doesn't then....
--- Roland Dreier <rdreier@...co.com> wrote:
> > struct mixart_enum_connector_resp *connector;
> > struct mixart_audio_info_req *audio_info_req;
> > struct mixart_audio_info_resp *audio_info;
> >
> > connector = kmalloc(sizeof(*connector), GFP_KERNEL);
> > audio_info_req = kmalloc(sizeof(*audio_info_req), GFP_KERNEL);
> > audio_info = kmalloc(sizeof(*audio_info), GFP_KERNEL);
> > if (! connector || ! audio_info_req || ! audio_info) {
> > err = -ENOMEM;
> > goto __error;
> > }
>
> This is not a bug. All of the pointers are initialized, and if
Yes, this is not a bug. Although the case for arrays go unnoticed by gcc. Something like this:
char *abcd[20];
int i;
for (i = 0; i < 20; i++) {
abcd[i] = kmalloc(10, GFP_KERNEL);
if (!abcd[i])
goto error;
}
error:
for (i = 0; i < 20; i++)
kfree(abcd[i]);
-Amit
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists