From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIv-0007cs-LS for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpLIm-0004Rf-02 for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIl-0004RX-Lk for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:19 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NEtIlc029259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Jan 2012 09:55:18 -0500 From: Gerd Hoffmann Date: Mon, 23 Jan 2012 15:54:52 +0100 Message-Id: <1327330511-16307-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1327330511-16307-1-git-send-email-kraxel@redhat.com> References: <1327330511-16307-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 06/25] usb: handle dev == NULL in usb_handle_packet() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 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