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 <kra...@redhat.com>
---
 hw/usb.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

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) {
-- 
1.7.1


Reply via email to