Re: [PATCH 2.6.16] rndis_host/cdc_ether: add support for Windows Mobile 5 based devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/30/06, Andrew Morton <[email protected]> wrote:
> "Ole André Vadla Ravnås" <[email protected]> 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.

Ahh, very good point there! Thanks for pointing it out!  I'll fix it,
wait for a comment from David, and then resubmit.

Cheers,
Ole Andre
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux