From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 31A9221F30413 for ; Thu, 28 Sep 2017 18:36:34 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 28 Sep 2017 18:39:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,451,1500966000"; d="scan'208";a="140737557" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 28 Sep 2017 18:39:48 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 28 Sep 2017 18:39:24 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 29 Sep 2017 09:38:50 +0800 From: "Yao, Jiewen" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Kinney, Michael D" Thread-Topic: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr Thread-Index: AQHTOMIqYcKcYaJyR0C5q9rqspKn+aLLFdYA Date: Fri, 29 Sep 2017 01:38:50 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A9C945C@shsmsx102.ccr.corp.intel.com> References: <20170929012741.4564-1-hao.a.wu@intel.com> In-Reply-To: <20170929012741.4564-1-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Sep 2017 01:36:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Friday, September 29, 2017 9:28 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Zeng, Star ; Kin= ney, > Michael D ; Yao, Jiewen > Subject: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to > check NULL ptr >=20 > Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for > checking NULL pointer dereference. >=20 > The ASSERT added here is for addressing a false positive NULL pointer > dereference issue raised from static analysis. >=20 > This commit adds comments to clarify the reason for using ASSERT as the > check. >=20 > Cc: Star Zeng > Cc: Michael D Kinney > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Core/Dxe/Hand/Handle.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c > b/MdeModulePkg/Core/Dxe/Hand/Handle.c > index 2db441725c..86a4065733 100644 > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c > @@ -1175,10 +1175,18 @@ Done: > // > if (!EFI_ERROR (Status) || Status =3D=3D EFI_ALREADY_STARTED) { > // > + // According to above logic, if 'Prot' is NULL, then the 'Status' = must be > + // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so > 'Prot' > + // must be not NULL. > + // > + // The ASSERT here is for addressing a false positive NULL pointer > + // dereference issue raised from static analysis. > + // > + ASSERT (Prot !=3D NULL); > + // > // EFI_ALREADY_STARTED is not an error for bus driver. > // Return the corresponding protocol interface. > // > - ASSERT (Prot !=3D NULL); > *Interface =3D Prot->Interface; > } else if (Status =3D=3D EFI_UNSUPPORTED) { > // > -- > 2.12.0.windows.1