[edk2-devel] [PATCH] SourceLevelDebugPkg DebugCommLibUsb3: Address NULL ptr dereference case

Zeng, Star posted 1 patch 4 years, 8 months ago
Failed in applying to current master (apply log)
.../DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c    | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH] SourceLevelDebugPkg DebugCommLibUsb3: Address NULL ptr dereference case
Posted by Zeng, Star 4 years, 8 months ago
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2051

Original code GetConfigTable for AddrPtr first, if failed,
InstalConfigTable with allocated AddrPtr. So the AddrPtr
should not be NULL and the NULL pointer dereference case
should be false positive. This patch is just to address
the case raised from static analysis.

Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
index eee30c852ffd..d4245465ce74 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
@@ -447,7 +447,7 @@ DebugCommunicationUsb3DxeConstructor (
   EFI_EVENT                     Event;
 
   Status = EfiGetSystemConfigurationTable (&gUsb3DbgGuid, (VOID **) &AddrPtr);
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (AddrPtr == NULL)) {
     //
     // Instead of using local variables, install system configuration table for
     // the local instance and the buffer to save instance address pointer.
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45252): https://edk2.groups.io/g/devel/message/45252
Mute This Topic: https://groups.io/mt/32806071/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] SourceLevelDebugPkg DebugCommLibUsb3: Address NULL ptr dereference case
Posted by Wu, Hao A 4 years, 8 months ago
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zeng, Star
> Sent: Friday, August 09, 2019 9:54 AM
> To: devel@edk2.groups.io
> Cc: Zeng, Star; Wu, Hao A
> Subject: [edk2-devel] [PATCH] SourceLevelDebugPkg DebugCommLibUsb3:
> Address NULL ptr dereference case
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2051
> 
> Original code GetConfigTable for AddrPtr first, if failed,
> InstalConfigTable with allocated AddrPtr. So the AddrPtr
> should not be NULL and the NULL pointer dereference case
> should be false positive. This patch is just to address
> the case raised from static analysis.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  .../DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c    | 2
> +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git
> a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Dxe.c
> b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Dxe.c
> index eee30c852ffd..d4245465ce74 100644
> ---
> a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Dxe.c
> +++
> b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Dxe.c
> @@ -447,7 +447,7 @@ DebugCommunicationUsb3DxeConstructor (
>    EFI_EVENT                     Event;
> 
>    Status = EfiGetSystemConfigurationTable (&gUsb3DbgGuid, (VOID **)
> &AddrPtr);
> -  if (EFI_ERROR (Status)) {
> +  if (EFI_ERROR (Status) || (AddrPtr == NULL)) {


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
And pushed via commit 4053587347.

Best Regards,
Hao Wu


>      //
>      // Instead of using local variables, install system configuration table for
>      // the local instance and the buffer to save instance address pointer.
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45331): https://edk2.groups.io/g/devel/message/45331
Mute This Topic: https://groups.io/mt/32806071/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-