From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4peX-0000uB-Dc for qemu-devel@nongnu.org; Mon, 23 May 2016 09:12:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4peS-0001CJ-GU for qemu-devel@nongnu.org; Mon, 23 May 2016 09:12:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4peS-0001CC-B8 for qemu-devel@nongnu.org; Mon, 23 May 2016 09:12:08 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6F63466F9 for ; Mon, 23 May 2016 13:12:07 +0000 (UTC) From: Gerd Hoffmann Date: Mon, 23 May 2016 15:12:03 +0200 Message-Id: <1464009123-5814-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1464009123-5814-1-git-send-email-kraxel@redhat.com> References: <1464009123-5814-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 4/4] usb/ohci: Fix crash with when specifying too many num-ports List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann From: Thomas Huth QEMU currently crashes when an OHCI controller is instantiated with too many ports, e.g. "-device pci-ohci,num-ports=100,masterbus=1". Thus add a proper check in usb_ohci_init() to make sure that we do not use more than OHCI_MAX_PORTS = 15 ports here. Ticket: https://bugs.launchpad.net/qemu/+bug/1581308 Signed-off-by: Thomas Huth Message-id: 1463995387-11710-1-git-send-email-thuth@redhat.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index ffab561..16d9ff7 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1848,6 +1848,12 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev, ohci->as = as; + if (num_ports > OHCI_MAX_PORTS) { + error_setg(errp, "OHCI num-ports=%d is too big (limit is %d ports)", + num_ports, OHCI_MAX_PORTS); + return; + } + if (usb_frame_time == 0) { #ifdef OHCI_TIME_WARP usb_frame_time = NANOSECONDS_PER_SECOND; -- 1.8.3.1