* RE: [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB.
@ 2003-05-07 5:06 Perez-Gonzalez, Inaky
2003-05-07 5:40 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-05-07 5:06 UTC (permalink / raw)
To: 'Greg KH', 'Max Krasnyansky'
Cc: 'Linux Kernel Mailing List',
'linux-usb-devel@lists.sourceforge.net'
> 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.
Sorry if this is a dup ... I am catching up with
my mail ...
Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB.
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
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2003-05-07 5:40 UTC (permalink / raw)
To: Perez-Gonzalez, Inaky
Cc: 'Max Krasnyansky', 'Linux Kernel Mailing List',
'linux-usb-devel@lists.sourceforge.net'
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB.
@ 2003-05-07 5:51 Perez-Gonzalez, Inaky
0 siblings, 0 replies; 3+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-05-07 5:51 UTC (permalink / raw)
To: 'Greg KH', Perez-Gonzalez, Inaky
Cc: 'Max Krasnyansky', 'Linux Kernel Mailing List',
'linux-usb-devel@lists.sourceforge.net'
> From: Greg KH [mailto:greg@kroah.com]
>
> > 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
Just documenting it should do :]
> 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" :)
Stab right in the heart :] I think we all agree we prefer "hardened
coders".
Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-07 5:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
-- strict thread matches above, loose matches on Subject: below --
2003-05-07 5:51 Perez-Gonzalez, Inaky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox