public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Oleg Drokin <green@linuxhacker.ru>
Cc: alan@redhat.com, linux-kernel@vger.kernel.org, greg@kroah.com
Subject: Re: [2.4] Memleak in drivers/usb/hub.c::usb_reset_device
Date: Wed, 12 Mar 2003 12:00:32 -0800	[thread overview]
Message-ID: <3E6F91E0.1020601@pacbell.net> (raw)
In-Reply-To: 20030312194133.GA27968@linuxhacker.ru

Oleg Drokin wrote:
> Hello!
> 
>    There seems to be a memleak in drivers/usb/hub.c::usb_reset_device()
>    on error exit path. See the patch.
>    Found with help of smatch + enhanced unfree script.

Hmm ... and 2.5 allocates it on the stack, which is actually
illegal (DMA-to-stack is nonportable).  This looks like a case
where it'd be good to make 2.5 look more like 2.4 (+ this patch).

- Dave


> Bye,
>     Oleg
> ===== drivers/usb/hub.c 1.19 vs edited =====
> --- 1.19/drivers/usb/hub.c	Sat Sep 21 00:12:53 2002
> +++ edited/drivers/usb/hub.c	Wed Mar 12 22:38:43 2003
> @@ -1057,8 +1057,10 @@
>  	}
>  	ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor,
>  			sizeof(*descriptor));
> -	if (ret < 0)
> +	if (ret < 0) {
> +		kfree(descriptor);
>  		return ret;
> +	}
>  
>  	le16_to_cpus(&descriptor->bcdUSB);
>  	le16_to_cpus(&descriptor->idVendor);
> 




  reply	other threads:[~2003-03-12 19:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-12 19:41 [2.4] Memleak in drivers/usb/hub.c::usb_reset_device Oleg Drokin
2003-03-12 20:00 ` David Brownell [this message]
2003-03-14 19:37 ` Greg KH
2003-03-14 20:02   ` Oleg Drokin
2003-03-19 23:32     ` Greg KH

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=3E6F91E0.1020601@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=alan@redhat.com \
    --cc=green@linuxhacker.ru \
    --cc=greg@kroah.com \
    --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