From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661371648372.23181891675074; Wed, 20 Feb 2019 03:16:11 -0800 (PST) Received: from localhost ([127.0.0.1]:38156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPrD-0001Qa-HI for importer@patchew.org; Wed, 20 Feb 2019 06:16:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpN-0008KF-Cx for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpM-0008L6-7w for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43196) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpK-0007Ri-RS for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48C9788312; Wed, 20 Feb 2019 11:13:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A6365D6B6; Wed, 20 Feb 2019 11:13:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DE5BB11AB5; Wed, 20 Feb 2019 12:13:46 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:38 +0100 Message-Id: <20190220111346.13669-2-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 11:13:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/9] usb: rearrange usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick There is no need to calculate the 'eps' variable in usb_ep_get() if 'ep' is the control endpoint. Instead the calculation should be done after validating the input before returning an entry indexed by the endpoint 'ep'. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda Reviewed-by: Ameya More Message-id: 1549460216-25808-2-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/core.c b/hw/usb/core.c index 241ae66b15..bfb7ae67bb 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -720,12 +720,12 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pi= d, int ep) if (dev =3D=3D NULL) { return NULL; } - eps =3D (pid =3D=3D USB_TOKEN_IN) ? dev->ep_in : dev->ep_out; if (ep =3D=3D 0) { return &dev->ep_ctl; } assert(pid =3D=3D USB_TOKEN_IN || pid =3D=3D USB_TOKEN_OUT); assert(ep > 0 && ep <=3D USB_MAX_ENDPOINTS); + eps =3D (pid =3D=3D USB_TOKEN_IN) ? dev->ep_in : dev->ep_out; return eps + ep - 1; } =20 --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661745591516.2626823586847; Wed, 20 Feb 2019 03:22:25 -0800 (PST) Received: from localhost ([127.0.0.1]:38244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPx9-0006SF-2z for importer@patchew.org; Wed, 20 Feb 2019 06:22:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpN-0008KD-CX for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpM-0008Kr-6A for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpK-0007Rh-PF for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 555C3E6A94; Wed, 20 Feb 2019 11:13:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B3B25D70E; Wed, 20 Feb 2019 11:13:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EF46611AB7; Wed, 20 Feb 2019 12:13:46 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:39 +0100 Message-Id: <20190220111346.13669-3-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 11:13:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] xhci: add asserts to help with static code analysis X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick Most callers of xhci_port_update() and xhci_wakeup() pass in a pointer to an array entry and can never be NULL but add two defensive asserts to protect against future changes (e.g. adding a new port speed, etc.) adding a path through xhci_lookup_port() that could result in the return of a NULL XHCIPort. Signed-off-by: Liam Merwick Message-id: 1549460216-25808-3-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 19c64f7ff4..99b83aaa9e 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2607,6 +2607,7 @@ static void xhci_port_update(XHCIPort *port, int is_d= etach) { uint32_t pls =3D PLS_RX_DETECT; =20 + assert(port); port->portsc =3D PORTSC_PP; if (!is_detach && xhci_port_have_device(port)) { port->portsc |=3D PORTSC_CCS; @@ -3215,6 +3216,7 @@ static void xhci_wakeup(USBPort *usbport) XHCIState *xhci =3D usbport->opaque; XHCIPort *port =3D xhci_lookup_port(xhci, usbport); =20 + assert(port); if (get_field(port->portsc, PORTSC_PLS) !=3D PLS_U3) { return; } --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661367366427.8627500989936; Wed, 20 Feb 2019 03:16:07 -0800 (PST) Received: from localhost ([127.0.0.1]:38153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPr6-0001JB-4G for importer@patchew.org; Wed, 20 Feb 2019 06:16:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpJ-0008HD-PB for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpG-00085g-El for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPp6-0007Xp-Vl for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:13:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD83FAC2C2; Wed, 20 Feb 2019 11:13:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3919417B15; Wed, 20 Feb 2019 11:13:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1622B11AB8; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:40 +0100 Message-Id: <20190220111346.13669-4-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 11:13:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] xhci: check device is not NULL before calling usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick Signed-off-by: Liam Merwick Message-id: 1549460216-25808-4-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 99b83aaa9e..ec28bee319 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3276,10 +3276,10 @@ static USBEndpoint *xhci_epid_to_usbep(XHCIEPContex= t *epctx) return NULL; } uport =3D epctx->xhci->slots[epctx->slotid - 1].uport; + if (!uport || !uport->dev) { + return NULL; + } token =3D (epctx->epid & 1) ? USB_TOKEN_IN : USB_TOKEN_OUT; - if (!uport) { - return NULL; - } return usb_ep_get(uport->dev, token, epctx->epid >> 1); } =20 --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661734253843.6272076862602; Wed, 20 Feb 2019 03:22:14 -0800 (PST) Received: from localhost ([127.0.0.1]:38242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPx4-0006N8-7Z for importer@patchew.org; Wed, 20 Feb 2019 06:22:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpP-0008Mc-EL for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpO-0008Qu-Bv for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpO-0007Yq-2A for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CF60C059B8C; Wed, 20 Feb 2019 11:13:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B6F7600C0; Wed, 20 Feb 2019 11:13:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2D7C516E03; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:41 +0100 Message-Id: <20190220111346.13669-5-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 11:13:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/9] ehci: check device is not NULL before calling usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick In ehci_process_itd(), the call to ehci_find_device() can return NULL if it doesn't find a device matching 'devaddr' so explicitly check the return value before passing it to usb_ep_get(). Signed-off-by: Liam Merwick Message-id: 1549460216-25808-5-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 9b132cb0d3..62dab0592f 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1439,9 +1439,12 @@ static int ehci_process_itd(EHCIState *ehci, qemu_sglist_add(&ehci->isgl, ptr1 + off, len); } =20 - pid =3D dir ? USB_TOKEN_IN : USB_TOKEN_OUT; - dev =3D ehci_find_device(ehci, devaddr); + if (dev =3D=3D NULL) { + ehci_trace_guest_bug(ehci, "no device found"); + return -1; + } + pid =3D dir ? USB_TOKEN_IN : USB_TOKEN_OUT; ep =3D usb_ep_get(dev, pid, endp); if (ep && ep->type =3D=3D USB_ENDPOINT_XFER_ISOC) { usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false, --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661546433792.5819011953065; Wed, 20 Feb 2019 03:19:06 -0800 (PST) Received: from localhost ([127.0.0.1]:38185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPu5-0003jt-Cz for importer@patchew.org; Wed, 20 Feb 2019 06:19:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpO-0008LA-8x for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpN-0008Nv-CP for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpM-0007V1-1B for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9951E81F0E; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5612F5D6B6; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 473AF16E05; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:42 +0100 Message-Id: <20190220111346.13669-6-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 11:13:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/9] ohci: check device is not NULL before calling usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick A call to ohci_find_device() can return NULL if it doesn't find a device matching 'addr' so for the two callers, explicitly check the return value before passing it to usb_ep_get(). Signed-off-by: Liam Merwick Message-id: 1549460216-25808-6-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index c34cf5b73a..196a9f7200 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -848,6 +848,10 @@ static int ohci_service_iso_td(OHCIState *ohci, struct= ohci_ed *ed, bool int_req =3D relative_frame_number =3D=3D frame_count && OHCI_BM(iso_td.flags, TD_DI) =3D=3D 0; dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); + if (dev =3D=3D NULL) { + trace_usb_ohci_td_dev_error(); + return 1; + } ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, false, int_r= eq); usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len); @@ -1071,6 +1075,10 @@ static int ohci_service_td(OHCIState *ohci, struct o= hci_ed *ed) return 1; } dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); + if (dev =3D=3D NULL) { + trace_usb_ohci_td_dev_error(); + return 1; + } ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, !flag_r, OHCI_BM(td.flags, TD_DI) =3D=3D 0); --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661821486148.80122991919097; Wed, 20 Feb 2019 03:23:41 -0800 (PST) Received: from localhost ([127.0.0.1]:38264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPyU-0007gZ-Gf for importer@patchew.org; Wed, 20 Feb 2019 06:23:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpO-0008L9-8r for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpN-0008OV-EQ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpM-0007bQ-6R for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F3893DD99; Wed, 20 Feb 2019 11:13:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5879C19C70; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5BC2016E07; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:43 +0100 Message-Id: <20190220111346.13669-7-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Feb 2019 11:13:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/9] uhci: check device is not NULL before calling usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick In uhci_handle_td(), the call to ehci_find_device() can return NULL if it doesn't find a device matching 'addr' so explicitly check the return value before passing it to usb_ep_get(). Signed-off-by: Liam Merwick Message-id: 1549460216-25808-7-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index e694b62086..09df29ff9c 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -858,13 +858,15 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,= uint32_t qh_addr, =20 /* Allocate new packet */ if (q =3D=3D NULL) { - USBDevice *dev =3D uhci_find_device(s, (td->token >> 8) & 0x7f); - USBEndpoint *ep =3D usb_ep_get(dev, pid, (td->token >> 15) & 0xf); + USBDevice *dev; + USBEndpoint *ep; =20 - if (ep =3D=3D NULL) { + dev =3D uhci_find_device(s, (td->token >> 8) & 0x7f); + if (dev =3D=3D NULL) { return uhci_handle_td_error(s, td, td_addr, USB_RET_NODEV, int_mask); } + ep =3D usb_ep_get(dev, pid, (td->token >> 15) & 0xf); q =3D uhci_queue_new(s, qh_addr, td, ep); } async =3D uhci_async_alloc(q, td_addr); --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661471806740.092167783338; Wed, 20 Feb 2019 03:17:51 -0800 (PST) Received: from localhost ([127.0.0.1]:38180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPss-0002pP-Ow for importer@patchew.org; Wed, 20 Feb 2019 06:17:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpJ-0008HE-PE for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpG-00085u-Fn for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPp6-0007bW-WA for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:00 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 463E5C08E2AA; Wed, 20 Feb 2019 11:13:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5997E1C929; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6BAA816E08; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:44 +0100 Message-Id: <20190220111346.13669-8-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 11:13:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/9] usb: check device is not NULL before calling usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick In musb_packet(), the call to usb_find_device() can return NULL if it doesn't find a device matching 'addr' so explicitly check the return value before passing it to usb_ep_get(). This then allows the subsequent calculation of 'id' to be streamlined. Signed-off-by: Liam Merwick Message-id: 1549460216-25808-8-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-musb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index d70a91a58c..85d7796554 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -628,11 +628,11 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *e= p, =20 /* A wild guess on the FADDR semantics... */ dev =3D usb_find_device(&s->port, ep->faddr[idx]); + if (dev =3D=3D NULL) { + return; + } uep =3D usb_ep_get(dev, pid, ep->type[idx] & 0xf); - id =3D pid; - if (uep) { - id |=3D (dev->addr << 16) | (uep->nr << 8); - } + id =3D pid | (dev->addr << 16) | (uep->nr << 8); usb_packet_setup(&ep->packey[dir].p, pid, uep, 0, id, false, true); usb_packet_addbuf(&ep->packey[dir].p, ep->buf[idx], len); ep->packey[dir].ep =3D ep; --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661629857578.5908146354849; Wed, 20 Feb 2019 03:20:29 -0800 (PST) Received: from localhost ([127.0.0.1]:38193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPvK-0004oi-Jk for importer@patchew.org; Wed, 20 Feb 2019 06:20:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpP-0008MJ-66 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpO-0008R8-DY for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpO-0007cW-3T for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A428B3DDB3; Wed, 20 Feb 2019 11:13:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B72F36FB; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 76AE316E0A; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:45 +0100 Message-Id: <20190220111346.13669-9-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Feb 2019 11:13:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/9] usb: add device checks before redirector calls to usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick Add an assert and an explicit check before the two callers to usb_ep_get() in the USB redirector code to ensure the device passed in is not NULL. Signed-off-by: Liam Merwick Message-id: 1549460216-25808-9-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/redirect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 18a42d1938..7cb6b120d4 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1728,6 +1728,7 @@ static void usbredir_ep_info(void *priv, USBRedirDevice *dev =3D priv; int i; =20 + assert(dev !=3D NULL); for (i =3D 0; i < MAX_ENDPOINTS; i++) { dev->endpoint[i].type =3D ep_info->type[i]; dev->endpoint[i].interval =3D ep_info->interval[i]; @@ -2125,7 +2126,7 @@ static int usbredir_post_load(void *priv, int version= _id) { USBRedirDevice *dev =3D priv; =20 - if (dev->parser =3D=3D NULL) { + if (dev =3D=3D NULL || dev->parser =3D=3D NULL) { return 0; } =20 --=20 2.9.3 From nobody Sun Nov 9 11:36:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550661665604304.0019414345337; Wed, 20 Feb 2019 03:21:05 -0800 (PST) Received: from localhost ([127.0.0.1]:38233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPvy-0005NX-Dx for importer@patchew.org; Wed, 20 Feb 2019 06:21:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwPpM-0008Iw-1f for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwPpK-0008H6-R8 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwPpJ-0007cc-SQ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 06:14:10 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAE5CC08E2B6; Wed, 20 Feb 2019 11:13:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-228.ams2.redhat.com [10.36.116.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91ACB5ED52; Wed, 20 Feb 2019 11:13:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9D64716E15; Wed, 20 Feb 2019 12:13:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 12:13:46 +0100 Message-Id: <20190220111346.13669-10-kraxel@redhat.com> In-Reply-To: <20190220111346.13669-1-kraxel@redhat.com> References: <20190220111346.13669-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 11:13:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 9/9] usb: remove unnecessary NULL device check from usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick No caller of usb_ep_get() calls it with a NULL device (previous commits have addressed the few remaining cases which didn't explicitly check). Replace check for 'dev =3D=3D NULL' with an assert instead. Signed-off-by: Liam Merwick Message-id: 1549460216-25808-10-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann --- hw/usb/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/usb/core.c b/hw/usb/core.c index bfb7ae67bb..8fbd9c7d57 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -717,9 +717,7 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid,= int ep) { struct USBEndpoint *eps; =20 - if (dev =3D=3D NULL) { - return NULL; - } + assert(dev !=3D NULL); if (ep =3D=3D 0) { return &dev->ep_ctl; } --=20 2.9.3