On Wed, 17 Dec 2003 12:29:45 -0500 John Homppi <[EMAIL PROTECTED]> wrote:
| [EMAIL PROTECTED] wrote: | >Date: Sat, 13 Dec 2003 15:37:23 -0800 | >From: Greg KH <[EMAIL PROTECTED]> | >To: John Homppi <[EMAIL PROTECTED]> | ........some lines snipped ....... | >> + if (dev->interrupt_out_buffer != NULL) { | >> + kfree (dev->interrupt_out_buffer); | >> + } | >> + kfree (dev); | > | >kfree can handle NULL as a paramater. You don't need to check it every | >time. | | But when I look at usb-skeleton.c in the 2.6.0-test11 tree I see that it | checks for NULL before calling kfree. umm. | static inline void skel_delete (struct usb_skel *dev) | { | if (dev->bulk_in_buffer != NULL) | kfree (dev->bulk_in_buffer); | if (dev->bulk_out_buffer != NULL) | usb_buffer_free (dev->udev, dev->bulk_out_size, | dev->bulk_out_buffer, | dev->write_urb->transfer_dma); | if (dev->write_urb != NULL) | usb_free_urb (dev->write_urb); | kfree (dev); | } | | So which is it? | Should my driver check for NULL before calling kfree? | Or is the code in usb-skeleton.c misleading? Accepted style is not to check for NULL before calling kfree(). Just let it do the work. -- ~Randy MOTD: Always include version info. ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel