mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: "Ole André Vadla Ravnås " <oleavr@gmail.com>
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: Wed, 29 Mar 2006 15:41:38 -0800	[thread overview]
Message-ID: <20060329154138.033eee05.akpm@osdl.org> (raw)
In-Reply-To: <c5e68b660603290342k2d46605bv5eeb4b341585e805@mail.gmail.com>

"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.



  reply	other threads:[~2006-03-29 23:39 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 [this message]
2006-03-30  3:12   ` Ole André Vadla Ravnås

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=20060329154138.033eee05.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleavr@gmail.com \
    /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®