[edk2-devel] [edk2-platform][PATCH v1 2/3] Platforms/RaspberryPi: Fix DwUsbHostDxe ComponentName2 error checking
Samer El-Haj-Mahmoud
samer.el-haj-mahmoud at arm.com
Sat Aug 15 20:26:30 UTC 2020
Fix input param error checking for the DwUsbHostDxe ComponentName2
protocol.
This fixes https://github.com/pftf/RPi4/issues/86
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/DwUsbHostDxe/DwUsbHostDxe.h | 4 +++-
Platform/RaspberryPi/Drivers/DwUsbHostDxe/ComponentName.c | 18 ++++++++++++++++++
Platform/RaspberryPi/Drivers/DwUsbHostDxe/DriverBinding.c | 2 +-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.h b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.h
index 106e5425355e..cf6c81b64ab5 100644
--- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.h
+++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.h
@@ -1,5 +1,6 @@
/** @file
*
+ * Copyright (c) 2020, ARM Limited. All rights reserved.
* Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin at gmail.com>
* Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
*
@@ -121,8 +122,9 @@ typedef struct _DWUSB_OTGHC_DEV {
UINT16 LastMicroFrame;
} DWUSB_OTGHC_DEV;
-extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
+extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL mDriverBinding;
EFI_STATUS
CreateDwUsbHc (
diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/ComponentName.c b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/ComponentName.c
index 2f3c53323bf1..8639ab7d39c5 100644
--- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/ComponentName.c
+++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/ComponentName.c
@@ -1,5 +1,6 @@
/** @file
*
+ * Copyright (c) 2020, ARM Limited. All rights reserved.
* Copyright (c) 2018, Andrey Warkentin <andrey.warkentin at gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -205,10 +206,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,
+ &gEfiUsb2HcProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
diff --git a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DriverBinding.c b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DriverBinding.c
index 7f78179d4c06..bada13a6cd7c 100644
--- a/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DriverBinding.c
+++ b/Platform/RaspberryPi/Drivers/DwUsbHostDxe/DriverBinding.c
@@ -36,7 +36,7 @@ DriverStop (
IN EFI_HANDLE *ChildHandleBuffer
);
-STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
DriverSupported,
DriverStart,
DriverStop,
--
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#64300): https://edk2.groups.io/g/devel/message/64300
Mute This Topic: https://groups.io/mt/76213600/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