mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Cc: Greg KH <greg@kroah.com>,
	linux-kernel@vger.kernel.org,
	linux-usb-devel@lists.sourceforge.net
Subject: Re: [PATCH 2.6.19-rc4] usb urb unlink/free clenup
Date: Mon, 6 Nov 2006 18:49:49 -0800	[thread overview]
Message-ID: <20061106184949.87b2f23a.akpm@osdl.org> (raw)
In-Reply-To: <200611062228.38937.m.kozlowski@tuxland.pl>

On Mon, 6 Nov 2006 22:28:37 +0100
Mariusz Kozlowski <m.kozlowski@tuxland.pl> wrote:

> Hello,
> 
> 
> 	In many places usb_(unlink,kill,free)_urb() are called this way:
> 
> if (urb)
> 	usb_something_urb(...);
> 
> which is not needed because functions like usb_unlink_urb() and usb_free_urb() are defined this way:
> 
> void usb_free_urb(struct urb *urb)
> {
>         if (urb)
>                 kref_put(&urb->kref, urb_destroy);
> }
> 
> int usb_unlink_urb(struct urb *urb)
> {
>         if (!urb)
>                 return -EINVAL;
> 	...
> }
> 
> We do not need to check for urb != NULL before we call them.

Seems reasonable.

Your patch had all its tabs replaced with spaces by your email client.  I
fixed that all up, but it was rather dull work and I'd prefer not to have
to do it again.

 It is also possible to do similar cleanup
> for usb_kill_urb(). The thing is it does urb check at the begining but right before is 
> might_sleep():
> 
> void usb_kill_urb(struct urb *urb)
> {
>         might_sleep();
>         if (!(urb && urb->dev && urb->dev->bus))
>                 return;
> 	...
> 
> which confuses me. I would like to know what to do about it. Can this be rewritten this way?:
> 
> void usb_kill_urb(struct urb *urb)
> {
> 	if (!urb)
> 		return;
>         might_sleep();
>         if (!urb->dev || !urb->dev->bus))
>                 return;
> 	...
> 
> Or maybe there is no need for this?
> 

I think it's OK as-is.  Presumably it's rare for a caller to pass in a NULL
urb.

It's possible that your proposed change will cause new (and incorrect)
warnings to be emitted, but we can handle those if/when they come out.


  reply	other threads:[~2006-11-07  2:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-06 21:28 Mariusz Kozlowski
2006-11-07  2:49 ` Andrew Morton [this message]
2006-11-07  9:30   ` Mariusz Kozlowski
2006-11-07  9:37     ` Andrew Morton
2006-11-08 14:33       ` [PATCH 1/33] usb: writing_usb_driver free urb cleanup Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 2/33] usb: pcwd_usb " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 3/33] usb: iforce-usb " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 4/33] usb: usb-gigaset free kill " Mariusz Kozlowski
2006-11-24 18:19         ` [linux-usb-devel] " Tilman Schmidt
2006-11-08 14:34       ` [PATCH 5/33] usb: cinergyT2 " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 6/33] usb: ttusb_dec free " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 7/33] usb: pvrusb2-hdw free unlink " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 8/33] usb: pvrusb2-io free " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 9/33] usb: pwc-if " Mariusz Kozlowski
2006-11-08 14:34       ` [PATCH 10/33] usb: sn9c102_core " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 11/33] usb: quickcam_messenger " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 12/33] usb: zc0301_core " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 13/33] usb: irda-usb " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 14/33] usb: zd1201 " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 15/33] usb: ati_remote " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 16/33] usb: ati_remote2 " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 17/33] usb: hid-core " Mariusz Kozlowski
2006-11-08 14:35       ` [PATCH 18/33] usb: usbkbd " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 19/33] usb: auerswald free kill urb cleanup and memleak fix Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 21/33] usb: phidgetkit free urb cleanup Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 20/33] usb: legousbtower free kill " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 22/33] usb: phidgetmotorcontrol free " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 23/33] usb: catc " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 24/33] usb: ftdi_sio kill " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 25/33] usb: io_edgeport " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 26/33] usb: keyspan free " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 27/33] usb: kobil_sct kill " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 28/33] usb: mct_u232 free " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 29/33] usb: navman kill " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 30/33] usb: usb-serial free " Mariusz Kozlowski
2006-11-08 14:36       ` [PATCH 31/33] usb: visor kill " Mariusz Kozlowski
2006-11-08 14:37       ` [PATCH 32/33] usb: usbmidi " Mariusz Kozlowski
2006-11-08 14:37       ` [PATCH 33/33] usb: usbmixer free " Mariusz Kozlowski

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=20061106184949.87b2f23a.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=m.kozlowski@tuxland.pl \
    /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®