From: "Ole André Vadla Ravnås" <oleavr@gmail.com>
To: "Andrew Morton" <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.16] rndis_host/cdc_ether: add support for Windows Mobile 5 based devices
Date: Thu, 30 Mar 2006 05:12:03 +0200 [thread overview]
Message-ID: <c5e68b660603291912o3d5ae0d9s8b9a99ab18d090da@mail.gmail.com> (raw)
In-Reply-To: <20060329154138.033eee05.akpm@osdl.org>
On 3/30/06, Andrew Morton <akpm@osdl.org> wrote:
> "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.
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
prev parent reply other threads:[~2006-03-30 3:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-29 11:42 Ole André Vadla Ravnås
2006-03-29 23:41 ` Andrew Morton
2006-03-30 3:12 ` Ole André Vadla Ravnås [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c5e68b660603291912o3d5ae0d9s8b9a99ab18d090da@mail.gmail.com \
--to=oleavr@gmail.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®