From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Lamparter Subject: Re: [PATCH 3/7] drivers/net/wireless/p54/eeprom.c: Return -ENOMEM on memory allocation failure Date: Fri, 15 Oct 2010 17:49:07 +0200 Message-ID: <201010151749.07851.chunkeey@googlemail.com> References: <1287147610-8041-3-git-send-email-julia@diku.dk> Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "John W. Linville" , linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Julia Lawall Return-path: In-Reply-To: <1287147610-8041-3-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org> Sender: linux-wireless-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: netdev.vger.kernel.org On Friday 15 October 2010 15:00:06 Julia Lawall wrote: > From: Julia Lawall > > In this code, 0 is returned on memory allocation failure, even though other > failures return -ENOMEM or other similar values. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // > @@ > expression ret; > expression x,e1,e2,e3; > @@ > > ret = 0 > ... when != ret = e1 > *x = \(kmalloc\|kcalloc\|kzalloc\)(...) > ... when != ret = e2 > if (x == NULL) { ... when != ret = e3 > return ret; > } > // > > Signed-off-by: Julia Lawall Cc: Acked-by: Christian Lamparter > --- > drivers/net/wireless/p54/eeprom.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff -u -p a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c > --- a/drivers/net/wireless/p54/eeprom.c > +++ b/drivers/net/wireless/p54/eeprom.c > @@ -261,8 +261,10 @@ static int p54_generate_channel_lists(st > list->max_entries = max_channel_num; > list->channels = kzalloc(sizeof(struct p54_channel_entry) * > max_channel_num, GFP_KERNEL); > - if (!list->channels) > + if (!list->channels) { > + ret = -ENOMEM; > goto free; > + } > > for (i = 0; i < max_channel_num; i++) { > if (i < priv->iq_autocal_len) { > > -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html