[edk2-devel] [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix DisplayDxe ComponentName2 error checking

Samer El-Haj-Mahmoud samer.el-haj-mahmoud at arm.com
Sat Aug 15 20:26:29 UTC 2020


Fix input param error checking for the DisplayDxe ComponentName2
protocol.

This fixes https://github.com/pftf/RPi4/issues/84

Cc: Leif Lindholm <leif at nuviainc.com>
Cc: Pete Batard <pete at akeo.ie>
Cc: Andrei Warkentin <awarkentin at vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel at arm.com>
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud at arm.com>
---
 Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.h    |  2 ++
 Platform/RaspberryPi/Drivers/DisplayDxe/ComponentName.c | 22 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.h b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.h
index bfbe9e868843..073f65111645 100644
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.h
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.h
@@ -1,5 +1,6 @@
 /** @file
  *
+ *  Copyright (c) 2020, ARM Limited. All rights reserved.
  *  Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin at gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.
  *
@@ -27,6 +28,7 @@
 extern EFI_GRAPHICS_OUTPUT_PROTOCOL gDisplayProto;
 extern EFI_COMPONENT_NAME_PROTOCOL  gComponentName;
 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL  mDriverBinding;
 
 VOID
 RegisterScreenshotHandlers (
diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/ComponentName.c b/Platform/RaspberryPi/Drivers/DisplayDxe/ComponentName.c
index 092230cd7c9b..4c065b5d51bf 100644
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/ComponentName.c
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/ComponentName.c
@@ -1,5 +1,6 @@
 /** @file
  *
+ *  Copyright (c) 2020, ARM Limited. All rights reserved.
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin at gmail.com>
  *  Copyright (c) 2006-2016, Intel Corporation. All rights reserved.
  *
@@ -206,6 +207,27 @@ ComponentNameGetControllerName (
   OUT CHAR16                      **ControllerName
   )
 {
+  EFI_STATUS  Status;
+
+  //
+  // This is a device driver, so ChildHandle must be NULL.
+  //
+  if (ChildHandle != NULL) {
+    return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Make sure this driver is currently managing ControllHandle
+  //
+  Status = EfiTestManagedDevice (
+             ControllerHandle,
+             mDriverBinding.DriverBindingHandle,
+             &gEfiGraphicsOutputProtocolGuid
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   return LookupUnicodeString2 (
            Language,
            This->SupportedLanguages,
-- 
2.17.1


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

View/Reply Online (#64302): https://edk2.groups.io/g/devel/message/64302
Mute This Topic: https://groups.io/mt/76213602/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list