EmbeddedPkg/CoherentDmaLib: Add missing checks to DmaMap
authorVladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Thu, 6 Sep 2018 18:55:03 +0000 (11:55 -0700)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 7 Sep 2018 10:23:32 +0000 (12:23 +0200)
UEFI Sct validates Dma mapping. For CoherentDmaLib it always failed
because there were no required checks present in DmaMap.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c

index 8ca9e6a..eb88fa2 100644 (file)
@@ -58,6 +58,12 @@ DmaMap (
   OUT    VOID                           **Mapping\r
   )\r
 {\r
   OUT    VOID                           **Mapping\r
   )\r
 {\r
+  if (HostAddress == NULL ||\r
+      NumberOfBytes == NULL ||\r
+      DeviceAddress == NULL ||\r
+      Mapping == NULL ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
   *DeviceAddress = HostToDeviceAddress (HostAddress);\r
   *Mapping = NULL;\r
   return EFI_SUCCESS;\r
   *DeviceAddress = HostToDeviceAddress (HostAddress);\r
   *Mapping = NULL;\r
   return EFI_SUCCESS;\r