From patchwork Tue Feb 28 10:20:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 143430 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 F2D33B6F62 for ; Tue, 28 Feb 2012 22:45:28 +1100 (EST) Received: from localhost ([::1]:42673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KCn-0002PQ-9u for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2012 05:22:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAx-00077Y-3z for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2KAj-000415-1r for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAi-00040Q-PM for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:40 -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 q1SAKdto004993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 05:20:39 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1SAKZJg032497; Tue, 28 Feb 2012 05:20:36 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 464B8412B0; Tue, 28 Feb 2012 11:20:30 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2012 11:20:18 +0100 Message-Id: <1330424430-23015-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1330424430-23015-1-git-send-email-kraxel@redhat.com> References: <1330424430-23015-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 09/21] usb-ehci: sanity-check iso xfers 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 This patch adds a sanity check to itd processing to make sure the endpoint addressed by the guest is actually an iso endpoint. Also verify that usb drivers don't return USB_RET_ASYNC which is illegal for iso xfers. Signed-off-by: Gerd Hoffmann --- hw/usb-ehci.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index b9da26a..048eb76 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1459,12 +1459,16 @@ static int ehci_process_itd(EHCIState *ehci, dev = ehci_find_device(ehci, devaddr); ep = usb_ep_get(dev, pid, endp); - usb_packet_setup(&ehci->ipacket, pid, ep); - usb_packet_map(&ehci->ipacket, &ehci->isgl); - - ret = usb_handle_packet(dev, &ehci->ipacket); - - usb_packet_unmap(&ehci->ipacket); + if (ep->type == USB_ENDPOINT_XFER_ISOC) { + usb_packet_setup(&ehci->ipacket, pid, ep); + usb_packet_map(&ehci->ipacket, &ehci->isgl); + ret = usb_handle_packet(dev, &ehci->ipacket); + assert(ret != USB_RET_ASYNC); + usb_packet_unmap(&ehci->ipacket); + } else { + DPRINTF("ISOCH: attempt to addess non-iso endpoint\n"); + ret = USB_RET_NAK; + } qemu_sglist_destroy(&ehci->isgl); #if 0