Patchwork [06/25] usb: handle dev == NULL in usb_handle_packet()

login
register
mail settings
Submitter Gerd Hoffmann
Date Jan. 23, 2012, 2:54 p.m.
Message ID <1327330511-16307-7-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/137401/
State New
Headers show

Comments

Gerd Hoffmann - Jan. 23, 2012, 2:54 p.m.
Allow passing in a NULL pointer, return USB_RET_NODEV in that case.
Removes the burden to to a NULL pointer check from the callers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/usb.c b/hw/usb.c
index 5482c92..80afd99 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -322,6 +322,10 @@  int usb_handle_packet(USBDevice *dev, USBPacket *p)
 {
     int ret;
 
+    if (dev == NULL) {
+        return USB_RET_NODEV;
+    }
+
     assert(p->owner == NULL);
     ret = dev->info->handle_packet(dev, p);
     if (ret == USB_RET_ASYNC) {