]> git.proxmox.com Git - mirror_qemu.git/commitdiff
usb: handle dev == NULL in usb_handle_packet()
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 10 Jan 2012 16:33:02 +0000 (17:33 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 10 Feb 2012 10:31:57 +0000 (11:31 +0100)
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

index bacdc81bfc4676a11dce4b4b4fb60de7d8449c1e..9976f81bd7d189c0ec16a9eb19bb73f62152d5d9 100644 (file)
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -315,6 +315,10 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
 {
     int ret;
 
+    if (dev == NULL) {
+        return USB_RET_NODEV;
+    }
+
     assert(p->owner == NULL);
     ret = usb_device_handle_packet(dev, p);
     if (ret == USB_RET_ASYNC) {