From nobody Fri May 17 15:22:32 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+106994+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+106994+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670925; cv=none; d=zohomail.com; s=zohoarc; b=BTSXb5+HAXwlnKdjASrgcm8pMUMSwN+gdHLHkk1BTpny1S9JPuL+RroCofGbNiI8ztF/BBJz6GdxpbzvkRas4VxXim0Pb4cj2BukXQCm7ljgq1lmyTmmzGtKMqMcTdbIabhfYrmtcomx+fd/LDv58CmGY19Gfm7OfCNPP8BtCAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670925; 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=Eqw17d6sY0Gfc3JX+Lq8joksk8irQI+IDqQv1zEZePE=; b=cO0gtXaHU0fYpWhe+1Ze2HQhTaijzKmLvhkLRXtXYg8GrJ4HqddXzvYCAXA0kgckwFC0CsCDTCPLdnzOdxxFygyKBam6Fc4/HlB6szKahsgAKK5JYCQH9FMOEYu7qv8WbPI+GqpZayKWE6A64XjK/OfzqN9oPnHdOpKrTQun5q8= 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+106994+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1689670925161662.9510449173123; Tue, 18 Jul 2023 02:02:05 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=iV/c/pRE9XF6jwv7tHBvy4F4Neh2WI09aRTsr+yO4Ao=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689670924; v=1; b=d0BQXNQnlH3IE0vC84U9Hhvnd60o461sWDjq2xMuPiKGl7KAsTmIAXosIVLG5kAyFP4TDAAa Zo8e7NJuyOHeUdtemt/5lXcXZ1fDzgCkEZn51XuZyCzhGUUoNskR4NOTF2mDDiV53TCiT2/XuuR mK+CuHzGD5zytP7UwPKDdYpw= X-Received: by 127.0.0.2 with SMTP id jf3kYY1788612xCwSpzBnxEE; Tue, 18 Jul 2023 02:02:04 -0700 X-Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mx.groups.io with SMTP id smtpd.web10.5970.1689593918585236682 for ; Mon, 17 Jul 2023 04:38:38 -0700 X-Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-666e916b880so2768156b3a.2 for ; Mon, 17 Jul 2023 04:38:38 -0700 (PDT) X-Gm-Message-State: VUzNYaPO21uC8vlweJTzhRcbx1787277AA= X-Google-Smtp-Source: APBJJlELr5SX/5Vz0XbDTdA4lCPueKkSOhEwTzjrtvvgpO55jtPn1gVGh74/Jb8BX44UaZQxDV7vlQ== X-Received: by 2002:a05:6a20:3d8a:b0:133:7fe3:6831 with SMTP id s10-20020a056a203d8a00b001337fe36831mr12838124pzi.57.1689593917743; Mon, 17 Jul 2023 04:38:37 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbd:8dd2:c2bf:93e0:5979:e5e0]) by smtp.gmail.com with ESMTPSA id a23-20020a637f17000000b0055b3af821d5sm12667349pgd.25.2023.07.17.04.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:38:37 -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/UhciDxe: Fix BAD_SHIFT Coverity issue Date: Mon, 17 Jul 2023 17:08:30 +0530 Message-Id: <20230717113831.2290882-2-rsingh@ventanamicro.com> In-Reply-To: <20230717113831.2290882-1-rsingh@ventanamicro.com> References: <20230717113831.2290882-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689670925753100017 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function UhciConvertPollRate has a check ASSERT (Interval !=3D 0); but this comes into play only in DEBUG mode. In Release mode, there is no handling if the Interval parameter value is ZERO. To avoid shifting by a negative amount later in the code flow in this undesirable case, it is better to handle it as well by simply returning ZERO. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4211 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/UhciDxe/UhciSched.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c b/MdeModulePkg/Bus/Pc= i/UhciDxe/UhciSched.c index c08f9496969b..8ddef4b68ccf 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c @@ -214,6 +214,10 @@ UhciConvertPollRate ( =20 ASSERT (Interval !=3D 0); =20 + if (Interval =3D=3D 0) { + return 0; + } + // // Find the index (1 based) of the highest non-zero bit // --=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 (#106994): https://edk2.groups.io/g/devel/message/106994 Mute This Topic: https://groups.io/mt/100212109/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 Fri May 17 15:22:32 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+106995+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+106995+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670924; cv=none; d=zohomail.com; s=zohoarc; b=gDPyauZd8eGI+O3wV7qqAAZToUQgg5Oz6MJexwJmSXvt+hhXVcFua4j1iW3pGJKbnxGHUnBh8Zlk/OZQ4LkuMCONCj9KSdGrAElWhN/UQTss5SJxEFqXT+qPg+Oe9mROD66tQ15KBVoLeOEjKlScPK6PuWuMwFCJTKTLT+kSPt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670924; 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=W5Ry44hhufALJB3SvFyZYcJdM4/nv3nHVmmUrFurjrU=; b=n8uTzPHhhRkBzxhU7bi8r17+6BNdjXpFTh362s1VwLCIL6Jlm4J4+lcUp3GJ7KGEKBEarBOKX3Z2AlAeVnnk9uLoUUhvJ9hGGU6y3DCrUHDnJXQ0YXSea1Wb9R/LXtFc069ir4hAmOk6sgVEJwCw95rJgs1OSmUMNNdhrG7qlag= 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+106995+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168967092465476.91016742655381; Tue, 18 Jul 2023 02:02:04 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=09wotRRfEj0V2lFkqp8Q64Vvl6u+t5TXONcZQCNf3yM=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689670924; v=1; b=Tcnn4jXRirL0PUmu0uLWvJkm6sxG6Ym0cMYhrte30WRvLtFfSXHDYGid19wicVTOQkFE1q8I NmCm5+VbgaeGv7ICEm3kvvMPBH0dqwT0Mo3hAGIU/Nzr9jpajnwxpAnOOq/98MUiA0SwJkIzXB2 Hk0LSf5a2hrulmcl4NdfPz1U= X-Received: by 127.0.0.2 with SMTP id 85xlYY1788612xi5CXJ7Wjr3; Tue, 18 Jul 2023 02:02:04 -0700 X-Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mx.groups.io with SMTP id smtpd.web10.5971.1689593920791735746 for ; Mon, 17 Jul 2023 04:38:40 -0700 X-Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6686c74183cso4485280b3a.1 for ; Mon, 17 Jul 2023 04:38:40 -0700 (PDT) X-Gm-Message-State: 1atC4jgY2DykIgWsU2FWamPPx1787277AA= X-Google-Smtp-Source: APBJJlEqpho8olFyaibRrQk61YHiYifHortfz7RgK7vbHhtBBEMo/IreuSkeeeimYcgZkUnF5HaHvQ== X-Received: by 2002:a05:6a00:2e98:b0:662:5146:c761 with SMTP id fd24-20020a056a002e9800b006625146c761mr17507414pfb.17.1689593920192; Mon, 17 Jul 2023 04:38:40 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbd:8dd2:c2bf:93e0:5979:e5e0]) by smtp.gmail.com with ESMTPSA id a23-20020a637f17000000b0055b3af821d5sm12667349pgd.25.2023.07.17.04.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:38:40 -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/UhciDxe: Fix FORWARD_NULL Coverity issues Date: Mon, 17 Jul 2023 17:08:31 +0530 Message-Id: <20230717113831.2290882-3-rsingh@ventanamicro.com> In-Reply-To: <20230717113831.2290882-1-rsingh@ventanamicro.com> References: <20230717113831.2290882-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689670925754100018 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function UsbHcGetPciAddressForHostMem has ASSERT ((Block !=3D NULL)); and and the function UsbHcFreeMem has ASSERT (Block !=3D NULL); statement 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=3D4211 Cc: Hao A Wu Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci= /UhciDxe/UsbHcMem.c index c3d46f60bed5..3794f888e132 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c @@ -250,6 +250,11 @@ UsbHcGetPciAddressForHostMem ( } =20 ASSERT ((Block !=3D NULL)); + + if (Block =3D=3D NULL) { + return 0; + } + // // calculate the pci memory address for host memory address. // @@ -536,6 +541,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 (#106995): https://edk2.groups.io/g/devel/message/106995 Mute This Topic: https://groups.io/mt/100212110/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-