From 98861f512bbd8789bd7935a75316d3278be23a0a Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 10 Jan 2012 17:33:02 +0100 Subject: usb: handle dev == NULL in usb_handle_packet() 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 --- hw/usb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw/usb.c') diff --git a/hw/usb.c b/hw/usb.c index bacdc81bfc..9976f81bd7 100644 --- 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) { -- cgit v1.2.3