From nobody Sat Nov 8 07:54:00 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; dkim=fail; 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=oracle.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549460521423952.7362307571069; Wed, 6 Feb 2019 05:42:01 -0800 (PST) Received: from localhost ([127.0.0.1]:51159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grNSd-0008UR-Bw for importer@patchew.org; Wed, 06 Feb 2019 08:41:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grNOJ-00057I-FW for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grNOD-0003nJ-QV for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:25 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:56810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grNOB-0003mb-Px for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:20 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x16DTd3C151284; Wed, 6 Feb 2019 13:37:17 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qd9argypv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 Feb 2019 13:37:17 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x16DbB1n008913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Feb 2019 13:37:11 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x16DbB51005882; Wed, 6 Feb 2019 13:37:11 GMT Received: from ol7.nl.oracle.com (/10.175.12.46) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Feb 2019 05:37:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=1Vjx4RlbPgDrl6VCVQV1AXrD7AXK0eoz1KMa/bITw84=; b=0jUaQ1PjvTh4Sf0xzmrxJ2Gx1NKzEaGaiKFjFWtmx5IABukk+idTwDcPBUeIlGSJRVLt donk5hTH7Vx6CVmeMHg8/dSKcuxPmjFC7gyRF1ce5ED2NKZV+PlfMSnHuKDxuZ1tlfA/ X83BuDTowHL1D2X9zdLvLKY+IkcRS5h1ThJ9UgNwsMJ18ho6qP7Kq+DXGivVL6/fBH72 qk6qZ28ZQRFPDZRasBGdNJl1LROiip8PGqsGd7ETl/hZpqKPWpPOKnKtRXvBQAsSCNCf 0AmajCC3rXHztx1/QIEoMRGWasWOwz9uWYBZRk467KPbwSM4EWfeYBnFKWS7af6YSb8H yw== From: Liam Merwick To: kraxel@redhat.com, qemu-devel@nongnu.org Date: Wed, 6 Feb 2019 13:36:49 +0000 Message-Id: <1549460216-25808-3-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549460216-25808-1-git-send-email-liam.merwick@oracle.com> References: <1549460216-25808-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9158 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=518 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902060107 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v2 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: darren.kenny@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 19c64f7ff421..99b83aaa9ed5 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 1.8.3.1