From nobody Sun Feb 8 07:33:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109273+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109273+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1696311552; cv=none; d=zohomail.com; s=zohoarc; b=IRe1uWVjj4vYeOXRrcdUDwxXTzxrOMgql10wwSEDyvHHn+fWV7lza+UFVPeKOBW3AteS2DsJjmHIzsq1q2JDkfwCTkjVcITyYL/5y8Q4NMVo5s47ESNt1aznW6xGFkMfNROUsHzrWAi8JQhqhJVn5RoYQmeRdwoBw03yycCSlcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696311552; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VI6R4PFTQCq4drTj4sCdym9/5if+K0v6q/QY4a7R5cY=; b=AghHuI2PIzn5B71jJ08JhmZyCDJu2FXaiEIjA58d5rcTAOiZnV3gvuRj598YI04CH/ETm6EzCpIAWrnLonHGi2vGAvTGH02d8zKKKsuRHSCqH5MT5dqaSWzdv3kswR/JUmbnUVtrj6FUfoo+77c+P2pjttHSfRHG1mq8e+bUtJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109273+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696311552809118.84648531434607; Mon, 2 Oct 2023 22:39:12 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=UqQc9Fmmn6Et8O4qMtV9SWgzI/D2tFPJhNnmpdvdbuI=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696311552; v=1; b=F/8LZB8MT9fQ9GtQ+GwgOQX6+LZWcyHPU3+6beXe+fHRbowy2zTYtkW1G36dKrBmtbZs3lw/ /tOThwtdBMIEUvlKBGEiNRzOSdmTfcZyAeLfYept3OwPJAnQF1ID1gl+VTeFXse29orWR6Ib/4v 7gAQexwTigHZBAzsDUfv8L/w= X-Received: by 127.0.0.2 with SMTP id w5qVYY1788612xIds1VkyryJ; Mon, 02 Oct 2023 22:39:12 -0700 X-Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by mx.groups.io with SMTP id smtpd.web11.102119.1696311551905780134 for ; Mon, 02 Oct 2023 22:39:12 -0700 X-Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-3515694c6d0so1782885ab.3 for ; Mon, 02 Oct 2023 22:39:11 -0700 (PDT) X-Gm-Message-State: fqPznkJOKxHKoFrui7h9pQlox1787277AA= X-Google-Smtp-Source: AGHT+IEAGaSsGg4l8nf+qesAODLFu+BpEBkki7SlVsOCx4oxePYNRYzfwB6Ywph8gdpcix7L890Utw== X-Received: by 2002:a05:6e02:1c25:b0:34f:d822:baab with SMTP id m5-20020a056e021c2500b0034fd822baabmr15905659ilh.12.1696311550894; Mon, 02 Oct 2023 22:39:10 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:1bb6:6659:f2cc:738a:e8e1]) by smtp.gmail.com with ESMTPSA id gj9-20020a0566386a0900b0041627abe120sm153973jab.160.2023.10.02.22.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 22:39:10 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 1/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix FORWARD_NULL Coverity issues Date: Tue, 3 Oct 2023 11:09:01 +0530 Message-Id: <20231003053902.27289-2-rsingh@ventanamicro.com> In-Reply-To: <20231003053902.27289-1-rsingh@ventanamicro.com> References: <20231003053902.27289-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696311554284100007 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The functions UsbHcGetHostAddrForPciAddr, UsbHcGetPciAddrForHostAddr and UsbHcFreeMem do have ASSERT ((Block !=3D NULL)); statements after for loop, but these are applicable only in DEBUG mode. In RELEASE mode, if for whatever reasons there is no match inside for loop and the loop exits because of Block !=3D NULL; condition, then there is no "Block" NULL pointer check afterwards and the code proceeds to do dereferencing "Block" which will lead to CRASH. Hence, for safety add NULL pointer checks always. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4221 Cc: Hao A Wu Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci= /XhciDxe/UsbHcMem.c index b54187ec228e..b0654f148c4f 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c @@ -267,6 +267,11 @@ UsbHcGetPciAddrForHostAddr ( } =20 ASSERT ((Block !=3D NULL)); + + if (Block =3D=3D NULL) { + return 0; + } + // // calculate the pci memory address for host memory address. // @@ -322,6 +327,11 @@ UsbHcGetHostAddrForPciAddr ( } =20 ASSERT ((Block !=3D NULL)); + + if (Block =3D=3D NULL) { + return 0; + } + // // calculate the pci memory address for host memory address. // @@ -603,6 +613,10 @@ UsbHcFreeMem ( // ASSERT (Block !=3D NULL); =20 + if (Block =3D=3D NULL) { + return; + } + // // Release the current memory block if it is empty and not the head // --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109273): https://edk2.groups.io/g/devel/message/109273 Mute This Topic: https://groups.io/mt/101729056/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun Feb 8 07:33:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109274+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109274+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1696311560; cv=none; d=zohomail.com; s=zohoarc; b=KiSz5Z1OQekWDENUwrNML9+SInmoxgTXtedfGc3d5UtA6VoTIH/0L9tWJzlw1ERmWaqLGtAqVmUjs5SbapbfqAVC1VmXZYXfz549ZOeH/hm4KXAobGfJXrYNydnchmybQyHdQPqQL1c35KN0M4+9pWH66P4iHf3K0RbKGosZyno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696311560; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=UdUXIKQTyoBwRCjBH5e2AQm11wdU0d4xUpI40LaYI9o=; b=nhrOGy7MZtM0GMfxvWSnsjZXhFiaN2vaNraERGJgWE+Qq/hsr04TJPaLm7rh0OHFtv8cHPJVhZc8sBCJ3p2UGWVsqUdLLPbuK5SRCEZ2QAhYvUKu/CE5St0R5MwOzPcClp6+kQUjtnfKx/cxgOqvKA0XXidvmickkr5dmE2mq64= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109274+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696311560679111.38233084934552; Mon, 2 Oct 2023 22:39:20 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=4ZeN0a9p72GPMddnjfzD1F/21HR9xdtXY46PY8s1TAY=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696311560; v=1; b=SGiN3BWm3xfhdsYqMA3IEAFG6AYBiJr/aEzH5Sp8l1J1SsoMBaFvN/i/mU8o4fjGEBIkvTng TzNVBKg9wZjwEtL6ZwZWJAJy8bnJXy+P4rUa1RmPN2g9Iznt+mivitQeGVJ/f7Asin6kwBIEYHE oaJroNlAgEZyAuWjp5Hdsqpw= X-Received: by 127.0.0.2 with SMTP id oK20YY1788612xIObdwuNXxi; Mon, 02 Oct 2023 22:39:20 -0700 X-Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by mx.groups.io with SMTP id smtpd.web11.102121.1696311554629962076 for ; Mon, 02 Oct 2023 22:39:14 -0700 X-Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-79fe6da0095so18809739f.0 for ; Mon, 02 Oct 2023 22:39:14 -0700 (PDT) X-Gm-Message-State: eWZEgWQDT8rSDRSTIje2nIP2x1787277AA= X-Google-Smtp-Source: AGHT+IH+ZznmZiCobImslwKMeectED/divh/lNd1mV3b56pyAtx3jkbS3N/Z77oB4QOAx7C3lAexPg== X-Received: by 2002:a6b:7314:0:b0:79f:d04d:ce59 with SMTP id e20-20020a6b7314000000b0079fd04dce59mr14412188ioh.6.1696311553723; Mon, 02 Oct 2023 22:39:13 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:1bb6:6659:f2cc:738a:e8e1]) by smtp.gmail.com with ESMTPSA id gj9-20020a0566386a0900b0041627abe120sm153973jab.160.2023.10.02.22.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 22:39:13 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 2/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix MISSING_BREAK Coverity issues Date: Tue, 3 Oct 2023 11:09:02 +0530 Message-Id: <20231003053902.27289-3-rsingh@ventanamicro.com> In-Reply-To: <20231003053902.27289-1-rsingh@ventanamicro.com> References: <20231003053902.27289-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696311562439100001 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The functions XhcInitializeEndpointContext and XhcInitializeEndpointContext64 has a switch-case code in which the case USB_ENDPOINT_CONTROL: falls through to default: While this may be intentional, it is not evident to any general code reader as well as any static analyzer tool. Just adding // No break; here as this is an intentional fallthrough. as comment in between makes any reader as well as Coverity happy. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4221 Cc: Hao A Wu Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 05528a478baf..2afecd40cab0 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -2979,6 +2979,9 @@ XhcInitializeEndpointContext ( // Do not support control transfer now. // DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unsupport Contr= ol EP found, Transfer ring is not allocated.\n")); + // + // No break; here as this is an intentional fall through. + // default: DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unknown EP foun= d, Transfer ring is not allocated.\n")); EpDesc =3D (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Len= gth); @@ -3182,6 +3185,9 @@ XhcInitializeEndpointContext64 ( // Do not support control transfer now. // DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport Con= trol EP found, Transfer ring is not allocated.\n")); + // + // No break; here as this is an intentional fall through. + // default: DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unknown EP fo= und, Transfer ring is not allocated.\n")); EpDesc =3D (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Len= gth); --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109274): https://edk2.groups.io/g/devel/message/109274 Mute This Topic: https://groups.io/mt/101729058/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-