From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 86721D80CAA for ; Tue, 18 Jul 2023 09:02:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KPSgCOBf+nIPTX6bndg7e/TA9SRTrIDRGiRJ86idfAs=; 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=1689670926; v=1; b=AJgcMwgbvZwxu1WDPxCjIWXxtAlApxMEVgo+ugMgFFBnZpnSz0L46rp6DK0y0v8aDTWasTVd WsCIpf77QNQTgpqJvvmTlofSBG+SJyiVCNxy78pNs9RkZVjrhWTvD9mkeQCn4w98wxt6e5UOMnK g0l4HXZNkTdY7ye3hZrJbPH0= X-Received: by 127.0.0.2 with SMTP id dakwYY7687511xHa9ZaS8VBk; Tue, 18 Jul 2023 02:02:06 -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: hk0ZvlI5iMfl0Hd7Ty9vG9xbx7686176AA= 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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=AJgcMwgb; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none 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 --- 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 ( }=0D =0D ASSERT ((Block !=3D NULL));=0D +=0D + if (Block =3D=3D NULL) {=0D + return 0;=0D + }=0D +=0D //=0D // calculate the pci memory address for host memory address.=0D //=0D @@ -536,6 +541,10 @@ UsbHcFreeMem ( //=0D ASSERT (Block !=3D NULL);=0D =0D + if (Block =3D=3D NULL) {=0D + return;=0D + }=0D +=0D //=0D // Release the current memory block if it is empty and not the head=0D //=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-