* [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr
@ 2017-09-29 1:27 Hao Wu
2017-09-29 1:38 ` Yao, Jiewen
0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2017-09-29 1:27 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Star Zeng, Michael D Kinney, Jiewen Yao
Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
checking NULL pointer dereference.
The ASSERT added here is for addressing a false positive NULL pointer
dereference issue raised from static analysis.
This commit adds comments to clarify the reason for using ASSERT as the
check.
Cc: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Core/Dxe/Hand/Handle.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
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 == 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 != NULL);
+ //
// EFI_ALREADY_STARTED is not an error for bus driver.
// Return the corresponding protocol interface.
//
- ASSERT (Prot != NULL);
*Interface = Prot->Interface;
} else if (Status == EFI_UNSUPPORTED) {
//
--
2.12.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr
2017-09-29 1:27 [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr Hao Wu
@ 2017-09-29 1:38 ` Yao, Jiewen
0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2017-09-29 1:38 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Zeng, Star, Kinney, Michael D
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 <hao.a.wu@intel.com>; Zeng, Star <star.zeng@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to
> check NULL ptr
>
> Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
> checking NULL pointer dereference.
>
> The ASSERT added here is for addressing a false positive NULL pointer
> dereference issue raised from static analysis.
>
> This commit adds comments to clarify the reason for using ASSERT as the
> check.
>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> MdeModulePkg/Core/Dxe/Hand/Handle.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> 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 == 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 != NULL);
> + //
> // EFI_ALREADY_STARTED is not an error for bus driver.
> // Return the corresponding protocol interface.
> //
> - ASSERT (Prot != NULL);
> *Interface = Prot->Interface;
> } else if (Status == EFI_UNSUPPORTED) {
> //
> --
> 2.12.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-29 1:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-29 1:27 [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr Hao Wu
2017-09-29 1:38 ` Yao, Jiewen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox