From patchwork Mon Jan 23 14:54:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 137401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8CBC41007D1 for ; Tue, 24 Jan 2012 03:22:04 +1100 (EST) Received: from localhost ([::1]:39640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLKZ-00036j-M2 for incoming@patchwork.ozlabs.org; Mon, 23 Jan 2012 09:57:11 -0500 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 Received: from rincewind.home.kraxel.org (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0NEtHtb014459; Mon, 23 Jan 2012 09:55:18 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 6782D40D2A; Mon, 23 Jan 2012 15:55:12 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 06/25] usb: handle dev == NULL in usb_handle_packet() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) {