From: Gerd Hoffmann Date: Tue, 10 Jan 2012 16:33:02 +0000 (+0100) Subject: usb: handle dev == NULL in usb_handle_packet() X-Git-Tag: v2.7.1~5485^2~19 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=98861f512bbd8789bd7935a75316d3278be23a0a;p=mirror_qemu.git 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 --- 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) {