]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg DebugCommLibUsb3: Address NULL ptr dereference case
authorZeng, Star <star.zeng@intel.com>
Fri, 9 Aug 2019 01:53:45 +0000 (09:53 +0800)
committerHao A Wu <hao.a.wu@intel.com>
Mon, 12 Aug 2019 01:46:47 +0000 (09:46 +0800)
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.

Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c

index eee30c852ffd35e20b70658565c2312d5e8883ef..d4245465ce74595fd0ae5084c46012af8a80943e 100644 (file)
@@ -447,7 +447,7 @@ DebugCommunicationUsb3DxeConstructor (
   EFI_EVENT                     Event;\r
 \r
   Status = EfiGetSystemConfigurationTable (&gUsb3DbgGuid, (VOID **) &AddrPtr);\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || (AddrPtr == NULL)) {\r
     //\r
     // Instead of using local variables, install system configuration table for\r
     // the local instance and the buffer to save instance address pointer.\r