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 <kraxel@redhat.com>
This commit is contained in:
parent
06c750888c
commit
98861f512b
4
hw/usb.c
4
hw/usb.c
@ -315,6 +315,10 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (dev == NULL) {
|
||||||
|
return USB_RET_NODEV;
|
||||||
|
}
|
||||||
|
|
||||||
assert(p->owner == NULL);
|
assert(p->owner == NULL);
|
||||||
ret = usb_device_handle_packet(dev, p);
|
ret = usb_device_handle_packet(dev, p);
|
||||||
if (ret == USB_RET_ASYNC) {
|
if (ret == USB_RET_ASYNC) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user