From nobody Tue May 21 05:16:18 2024 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+110808+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+110808+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1699336690; cv=none; d=zohomail.com; s=zohoarc; b=RMS6GKjA6oYgZi6N/CLWCsaiqY/ZHUkdqsXE0KjRPzHYOQM6a9ZSFBMNsD5pzve/+WgE0/2e/AZoIpoHvNS7NzGaIwxxejewofCqPpinncZifNXMxo/6lCqIDqjjnS10GQzBGbEmTjdDM2i9qCjvdVUFHKrJyHc8mVanUKcargs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699336690; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=FxE5l3FNGw9N+kGJK4njbn0WdXvL/irkFdFYKT5mdj8=; b=fUTgiW7B2fvYKEx8BgmR5SU0UBGJzaZ7fs3gny3eE31V9yz8dxkEazw25oVVC/957xcAb2+c7gupFO8K0jSSoKWROkui3pKceT9w17sm+AiW6vZmYC+CHc/ukKP/FZR7y76JJgWrDUBW+cDk6FJ8TYSp0EsjbOV32ekThqO6PCs= 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+110808+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169933669091014.59754884738527; Mon, 6 Nov 2023 21:58:10 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=k1DYPzIZoIBtpnfYSD+03YZFaQVdEn4+yPRbpayfKuA=; 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=1699336690; v=1; b=puMXup+Iev59hvhwSClOO2wrz0evRFtxDgHBxqONEzmNZUaUBB0jLKinzzAjPi5m8OO6raIP tjlvcqSA20zBVtd+FwtbZ51LUI7PLbdCXwTc5EwlhaonqtxenqUT0P2RMsIa82x9Aiv9H42JZ2b pgcv/gnZ2QnbPl3Yb7fs1+2g= X-Received: by 127.0.0.2 with SMTP id RRfUYY1788612xO3nubcp4iW; Mon, 06 Nov 2023 21:58:10 -0800 X-Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) by mx.groups.io with SMTP id smtpd.web11.4425.1699336689906175511 for ; Mon, 06 Nov 2023 21:58:10 -0800 X-Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-4ac05ca3935so1149772e0c.1 for ; Mon, 06 Nov 2023 21:58:09 -0800 (PST) X-Gm-Message-State: 8A7ExA4UUV29w8AEm0QTWWhhx1787277AA= X-Google-Smtp-Source: AGHT+IEsZxLwrZn8jlWPwPOe4DJNkZwIhhVIKZS4I/2WPybNsKmybDJWE9sRndQvmpiKH0WEHAVsZg== X-Received: by 2002:a1f:a792:0:b0:496:2e22:29e3 with SMTP id q140-20020a1fa792000000b004962e2229e3mr26912125vke.1.1699336688680; Mon, 06 Nov 2023 21:58:08 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id d20-20020a02a494000000b0042b16c005e9sm2607854jam.124.2023.11.06.21.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 21:58:08 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix FORWARD_NULL Coverity issues Date: Tue, 7 Nov 2023 11:27:59 +0530 Message-Id: <20231107055800.86752-2-rsingh@ventanamicro.com> In-Reply-To: <20231107055800.86752-1-rsingh@ventanamicro.com> References: <20231107055800.86752-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: 1699336691586100005 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: 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 (#110808): https://edk2.groups.io/g/devel/message/110808 Mute This Topic: https://groups.io/mt/102438127/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 Tue May 21 05:16:18 2024 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+110809+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+110809+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1699336693; cv=none; d=zohomail.com; s=zohoarc; b=DBiCZJuRJC53+EhO++rrjG0QK95ZEPKQzHNRu7vlODJM/MIWsBKPaXots+bwozScMuFopSw0pIVszz8e6LF47niKU/Y2idbFTzxrlwjFEZhufZzMSn4oJxolg/flPYeunKxp5v0iEKVzxrSbhQOOWgsHixM1ZrZ5C/zCuLnDPvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699336693; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=e6CK+HaPHaT7h0IIXVqlP/f5jE1gssOHFrU/rL5hY3w=; b=WIS7RvgqE5i7piS8ypwlCpBkbYZXOQcOT3VS3c5Dzyrof4nH2mvi9LJGb+VlKhYKmziu1lB0rJ/1y6VP0fZ3X3N/s9OVMWcMRRB9Zf6esBEM6nYxIpQiOX28wEv79cjjE/UdoExQa7/TCPmuEO2sEO4QwJ52qaPdd8ITeX3kq0g= 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+110809+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699336693436635.9046667723569; Mon, 6 Nov 2023 21:58:13 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=24kXDjJ6zAxjwyhEiFbR9+jufcPzrpwJ1WVzjjJqIsI=; 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=1699336693; v=1; b=C4xZoO5CmMrXG2jhPr5IHKdmQ3PTV3jvzlFGSiWxLDKR6BeJjbwBAPth8gFnt28M/WbTolt8 F81YCxkYXrMGonAEaBXudta2jqVGxoY+y/RdpZvkdrv58tv5tjkQu+n4fsrqelbdFS3iDF/YE48 9vjg1W96Js7bVcd4maGTRHz4= X-Received: by 127.0.0.2 with SMTP id QnHiYY1788612xioqy6kBJcQ; Mon, 06 Nov 2023 21:58:13 -0800 X-Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) by mx.groups.io with SMTP id smtpd.web10.4798.1699336692447448917 for ; Mon, 06 Nov 2023 21:58:12 -0800 X-Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-49d8dd34f7bso2127667e0c.3 for ; Mon, 06 Nov 2023 21:58:12 -0800 (PST) X-Gm-Message-State: ANg86SDt99CwSwqaR9LT7x3Ax1787277AA= X-Google-Smtp-Source: AGHT+IGumW6lLBhj7qz3vx9nmoTZ0Ov9DfINKndI55oOEtKv4+dUMAaYbyt/elNELUz5j/zjpJ8VhA== X-Received: by 2002:a1f:26c6:0:b0:49a:bff1:23 with SMTP id m189-20020a1f26c6000000b0049abff10023mr28162422vkm.5.1699336691324; Mon, 06 Nov 2023 21:58:11 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id d20-20020a02a494000000b0042b16c005e9sm2607854jam.124.2023.11.06.21.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 21:58:11 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 2/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix MISSING_BREAK Coverity issues Date: Tue, 7 Nov 2023 11:28:00 +0530 Message-Id: <20231107055800.86752-3-rsingh@ventanamicro.com> In-Reply-To: <20231107055800.86752-1-rsingh@ventanamicro.com> References: <20231107055800.86752-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: 1699336695603100011 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 why there is no break; in between. Adding // No break; here as this is an intentional fallthrough. as comment in between makes it explicit. Incidentally, the comment satisfies Coverity as well. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4221 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 (#110809): https://edk2.groups.io/g/devel/message/110809 Mute This Topic: https://groups.io/mt/102438128/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-