From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvotE-00062y-Jt for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:43:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvot5-0000Ha-3T for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:43:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvot4-0000HI-OF for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:43:35 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1ABhXsE012929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Feb 2012 06:43:33 -0500 From: Gerd Hoffmann Date: Fri, 10 Feb 2012 12:43:05 +0100 Message-Id: <1328874204-20920-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1328874204-20920-1-git-send-email-kraxel@redhat.com> References: <1328874204-20920-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 09/28] 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 bacdc81..9976f81 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) { -- 1.7.1