From patchwork Tue Jan 8 13:14:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 210373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BDD1C2C0087 for ; Wed, 9 Jan 2013 00:16:33 +1100 (EST) Received: from localhost ([::1]:52353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ2d-0006LV-PQ for incoming@patchwork.ozlabs.org; Tue, 08 Jan 2013 08:16:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ1R-0004sw-VA for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:15:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsZ1Q-0002xa-IF for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:15:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsZ1Q-0002xT-AW for qemu-devel@nongnu.org; Tue, 08 Jan 2013 08:15:16 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08DFDOR024738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Jan 2013 08:15:15 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r08DF0vv024565; Tue, 8 Jan 2013 08:15:01 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 0870F41B98; Tue, 8 Jan 2013 14:14:55 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 8 Jan 2013 14:14:48 +0100 Message-Id: <1357650894-16982-27-git-send-email-kraxel@redhat.com> In-Reply-To: <1357650894-16982-1-git-send-email-kraxel@redhat.com> References: <1357650894-16982-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 26/32] xhci: call set-address with dummy usbpacket 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 Due to the way devices are addressed with xhci (done by hardware, not the guest os) there is no packet when invoking the set-address control request. Create a dummy packet in that case to avoid null pointer dereferences. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 40542b8..9132920 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1970,13 +1970,18 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { + USBPacket p; slot->devaddr = xhci->devaddr++; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slot->devaddr; DPRINTF("xhci: device address is %d\n", slot->devaddr); usb_device_reset(dev); - usb_device_handle_control(dev, NULL, + usb_packet_setup(&p, USB_TOKEN_OUT, + usb_ep_get(dev, USB_TOKEN_OUT, 0), + 0, false, false); + usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slot->devaddr, 0, 0, NULL); + assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);