From nobody Thu May 16 14:11:38 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+107789+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+107789+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1692164290; cv=none; d=zohomail.com; s=zohoarc; b=adhAxJyxO//ZzeMhcQVvGmLGF33527eoi9VWVu1TWwcxiFXCH3NBkKk7dBmAW+xR5M6kiqKX13hQ8D0Veh3YitxIgkeJsIP0X0C6x94PuIhbQ8qOJjfX2A2N+ibHks6QUsnaENahKNcnNVeH0yRWLW9NCaR2HwBD7JsdOmmoYxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692164290; 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=EbFCMKLKxj+Zg+gVei8DB0/Dhwlx0E/ILeW2TzJ+WkY=; b=CHTjLiNCeXNXhJHH1I287Lw/mrq3xncq8bvQqMFAc1WOFwfMRLqZG9p6fc8oVMJBDtzAXsqbQ+qtnlUvEZYAvh1T8aPf6NcajblSsFTahM+F+A7bTj9LKz0hmz6tH3LZGDGJiynMtmCF8Im0en7WjYhrTd5cFkNUPdhHa4vzCHI= 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+107789+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1692164290521973.7777239815625; Tue, 15 Aug 2023 22:38:10 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pnYjE3icGwfliW85EQel/cM/6I5gsZqImMYIQRFrqhU=; 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=1692164290; v=1; b=fVbyZqBt+05QLOEw1DD1zHOZH2TGBgR++745P+GlYN5DcUeIPA+umHHubhE1DVtN+j28yc+I qYNJxIjl/MHOY2rcawEpxuH2p7N96uP4JhhiSrNeCGtpJ21GSL7xUYttmTFT2wPdEdyTJZv+IVD Zf0OFVCCuvi/OGw83ZKDQGaA= X-Received: by 127.0.0.2 with SMTP id IJMqYY1788612xJUmv0K00uf; Tue, 15 Aug 2023 22:38:10 -0700 X-Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web11.154668.1692164289223126602 for ; Tue, 15 Aug 2023 22:38:09 -0700 X-Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6887b3613e4so458978b3a.3 for ; Tue, 15 Aug 2023 22:38:09 -0700 (PDT) X-Gm-Message-State: VUOUkIXZt36ve6yl43TNGyYbx1787277AA= X-Google-Smtp-Source: AGHT+IEQHN8ZwGbz9+5hcV00hIAd6EHln9OXbu/gfu+XFYhEJtvZ/DQMzneSnj8vX84ZU9qxV53URw== X-Received: by 2002:a05:6a21:7985:b0:13b:c4a8:1a68 with SMTP id bh5-20020a056a21798500b0013bc4a81a68mr1215337pzc.34.1692164288561; Tue, 15 Aug 2023 22:38:08 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id p2-20020aa78602000000b006889081281bsm424737pfn.138.2023.08.15.22.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 22:38:08 -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 v2 1/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix BAD_SHIFT Coverity issue Date: Wed, 16 Aug 2023 11:08:02 +0530 Message-Id: <20230816053803.1142517-2-rsingh@ventanamicro.com> In-Reply-To: <20230816053803.1142517-1-rsingh@ventanamicro.com> References: <20230816053803.1142517-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: 1692164291099100004 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 treating it same as if 1 is sent. 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/UhciSched.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c b/MdeModulePkg/Bus/Pc= i/UhciDxe/UhciSched.c index c08f9496969b..408e7d5ab7f3 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c @@ -197,7 +197,7 @@ UhciDestoryFrameList ( } =20 /** - Convert the poll rate to the maxium 2^n that is smaller + Convert the poll rate to the maximum 2^n that is smaller than Interval. =20 @param Interval The poll rate to convert. @@ -214,6 +214,14 @@ UhciConvertPollRate ( =20 ASSERT (Interval !=3D 0); =20 + // + // To safeguard RELEASE mode wherein ASSERT is effectively not there, + // if inadvertently Interval is still 0 here, treat it the same as 1. + // + if (Interval =3D=3D 0) { + Interval =3D 1; + } + // // 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 (#107789): https://edk2.groups.io/g/devel/message/107789 Mute This Topic: https://groups.io/mt/100774224/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 Thu May 16 14:11:38 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+107790+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+107790+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1692164292; cv=none; d=zohomail.com; s=zohoarc; b=Nex5fjrpVLKwhDYQHryR8e74bmlMFfjHMEtuCwjOAYUZIIRQXQD8B6MGZEkc0Ma/UB8iI/HVU6NuoZR8r9lf/HBh4I0T3GPsDByMO0w6oCzgNpL3cWUORK/HS3f1rN90YTkwaM817IJR8/WTAYhl2c+LD9a86vClyVHLe6hGtXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692164292; 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=ztDuuZjsIwTQW6cMI+bx/jLAXfCKiH1mD4hVw8zmvvU=; b=QBmOJJFRM8zaGRzk/s/4rhTLE1YiLVvJi/d1lDA7YN+FkOm2ZL2NExE41XPqjJLfdlm4Gb0eR3JxR1ypxS4Q0XHiMJrlXNX879/iZvr+IZ0tJJ4LBfwI0ysK48EzfmS+F2i474CYguKSJQ+dAKW1TRUnu4zU/GAd+T5mDVcQ8rE= 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+107790+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1692164292193861.5961513912398; Tue, 15 Aug 2023 22:38:12 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pQAxr4V2z4ncikls6wNSbrhmkvike53xPTyj0koSmh0=; 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=1692164291; v=1; b=I4B9SD5E7SyFY7wZcN8ayjCI9+WJuVuQM9ATcKWYNJe/XZGNYdRZbygfUqY5MZzwVppbF4yT Z1RJ/xO2DTsrbKg6x/gkXfTNBgVdSJopidtTyUa2Em5RKaOHAUWy2uFhDAUPvUokX8NMZzG8VLj pj7tJapIpnakHX2OBsbLQeus= X-Received: by 127.0.0.2 with SMTP id oh1YYY1788612xJcNw0c4uxl; Tue, 15 Aug 2023 22:38:11 -0700 X-Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mx.groups.io with SMTP id smtpd.web10.154871.1692164291253713529 for ; Tue, 15 Aug 2023 22:38:11 -0700 X-Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5650ec45a7cso3618502a12.3 for ; Tue, 15 Aug 2023 22:38:11 -0700 (PDT) X-Gm-Message-State: 8Kquk5AEuw3YB7OnjLkKAMzix1787277AA= X-Google-Smtp-Source: AGHT+IFHxVaMMdSw5+jpxOJNffi82b7LVlEARoB+4uXgNQm1K8csu0c0XOWpF5CmeD8bEpRzAqSP/Q== X-Received: by 2002:a05:6a21:7781:b0:13b:7533:6839 with SMTP id bd1-20020a056a21778100b0013b75336839mr1090699pzc.29.1692164290531; Tue, 15 Aug 2023 22:38:10 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id p2-20020aa78602000000b006889081281bsm424737pfn.138.2023.08.15.22.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 22:38: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 v2 2/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix FORWARD_NULL Coverity issues Date: Wed, 16 Aug 2023 11:08:03 +0530 Message-Id: <20230816053803.1142517-3-rsingh@ventanamicro.com> In-Reply-To: <20230816053803.1142517-1-rsingh@ventanamicro.com> References: <20230816053803.1142517-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: 1692164293122100011 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 (#107790): https://edk2.groups.io/g/devel/message/107790 Mute This Topic: https://groups.io/mt/100774225/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-