Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262869AbTEGF2x (ORCPT ); Wed, 7 May 2003 01:28:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262873AbTEGF2x (ORCPT ); Wed, 7 May 2003 01:28:53 -0400 Received: from granite.he.net ([216.218.226.66]:38160 "EHLO granite.he.net") by vger.kernel.org with ESMTP id S262869AbTEGF2v (ORCPT ); Wed, 7 May 2003 01:28:51 -0400 Date: Tue, 6 May 2003 22:40:59 -0700 From: Greg KH To: "Perez-Gonzalez, Inaky" Cc: "'Max Krasnyansky'" , "'Linux Kernel Mailing List'" , "'linux-usb-devel@lists.sourceforge.net'" Subject: Re: [Bluetooth] HCI USB driver update. Support for SCO over HCI U SB. Message-ID: <20030507054059.GA6138@kroah.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1243 Lines: 43 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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/