Hi,

kfree() handles NULL arguments which is handy in error handling paths as one
does need to  insert bunch of ifs. How about making usb_buffer_free() do the
same?

BTW, checking for !dev->bus and !dev->bus->op and !dev->bus->op->buffer_free
seems to be superfluos - we already checked that the device has bus and
bus ops and if device has buffer_alloc() then it has to have buffer_free()
as well. Should extra checks be killed?

-- 
Dmitry



USB: make usb_buffer_free() NULL-safe

Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]>
---

 drivers/usb/core/usb.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Index: work/drivers/usb/core/usb.c
===================================================================
--- work.orig/drivers/usb/core/usb.c
+++ work/drivers/usb/core/usb.c
@@ -751,7 +751,7 @@ void *usb_buffer_alloc (
  *
  * This reclaims an I/O buffer, letting it be reused.  The memory must have
  * been allocated using usb_buffer_alloc(), and the parameters must match
- * those provided in that allocation request. 
+ * those provided in that allocation request.
  */
 void usb_buffer_free (
        struct usb_device *dev,
@@ -761,7 +761,9 @@ void usb_buffer_free (
 )
 {
        if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free)
-               return;
+               return;
+       if (!addr)
+               return;
        dev->bus->op->buffer_free (dev->bus, size, addr, dma);
 }
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to