lkml.org 
[lkml]   [2006]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2.6.16] rndis_host/cdc_ether: add support for Windows Mobile 5 based devices
"Ole André Vadla Ravnås" <oleavr@gmail.com> wrote:
>
> + /* allocate and fill in the missing structures */
> + h = kmalloc(sizeof(struct usb_cdc_header_desc), GFP_KERNEL);
> + if (!h)
> + return -ENOMEM;
> + info->header = h;
> +
> + h->bLength = sizeof(struct usb_cdc_header_desc);
> + h->bDescriptorType = USB_DT_CS_INTERFACE;
> + h->bDescriptorSubType = USB_CDC_HEADER_TYPE;
> +
> + h->bcdCDC = 0; /* FIXME */
> +
> + u = kmalloc(sizeof(struct usb_cdc_union_desc), GFP_KERNEL);
> + if (!u)
> + return -ENOMEM;
> + info->u = u;

If the second kmalloc() fails, do we leak the memory at `h'?

Please don't sprinkle `return' statements deep inside large and complex
functions. It makes the code hard to audit and to modify and it invites
resource leaks and locking errors. Instead, use `goto suitable_unwind_point;', thanks.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-30 01:41    [from the cache]
©2003-2011 Jasper Spaans