public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: "Perez-Gonzalez, Inaky" <inaky.perez-gonzalez@intel.com>
Cc: "'Max Krasnyansky'" <maxk@qualcomm.com>,
	"'Linux Kernel Mailing List'" <linux-kernel@vger.kernel.org>,
	"'linux-usb-devel@lists.sourceforge.net'" 
	<linux-usb-devel@lists.sourceforge.net>
Subject: Re: [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB.
Date: Tue, 6 May 2003 22:40:59 -0700	[thread overview]
Message-ID: <20030507054059.GA6138@kroah.com> (raw)
In-Reply-To: <A46BBDB345A7D5118EC90002A5072C780C8FDF50@orsmsx116.jf.intel.com>

On Tue, May 06, 2003 at 10:06:22PM -0700, Perez-Gonzalez, Inaky wrote:
> 
> 
> > From: Greg KH [mailto:greg@kroah.com]
> >
> > +int usb_init_urb(struct urb *urb)
> > +{
> > +	if (!urb)
> > +		return -EINVAL;
> > ...
> > ...
> > ...
> > @@ -38,13 +61,14 @@
> >  		mem_flags);
> >  	if (!urb) {
> >  		err("alloc_urb: kmalloc failed");
> > -		return NULL;
> > +		goto exit;
> > +	}
> > +	if (usb_init_urb(urb)) {
> > +		kfree(urb);
> > +		urb = NULL;
> >  	}
> 
> If usb_init_urb() is already testing for !urb, why
> test it again? No doubt the compiler will probably
> catch it if inlining ... but I think the best is
> for usb_init_urb() to assume that urb is not NULL.
> Let the caller make that sure.

Because people other than usb_alloc_urb() can call usb_init_urb().
Yeah, I can remove the check, then any invalid caller will oops on the
first line of usb_init_urb().  I don't mind, was just trying to program
a bit more defensibly.  You know, make it a "hardened driver"  :)

thanks,

greg k-h

  reply	other threads:[~2003-05-07  5:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-07  5:06 [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB Perez-Gonzalez, Inaky
2003-05-07  5:40 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-05-07  5:51 Perez-Gonzalez, Inaky

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=20030507054059.GA6138@kroah.com \
    --to=greg@kroah.com \
    --cc=inaky.perez-gonzalez@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=maxk@qualcomm.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