[edk2-devel] [edk2-platform][PATCH v1 3/3] Platforms/RaspberryPi: Fix BcmGenetDxe ComponentName2 error checking
Samer El-Haj-Mahmoud
samer.el-haj-mahmoud at arm.com
Sat Aug 15 20:26:31 UTC 2020
Fix input param error checking for the BcmGenetDxe ComponentName2
protocol.
This fixes https://github.com/pftf/RPi4/issues/85
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>
---
Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.h | 1 +
Silicon/Broadcom/Drivers/Net/BcmGenetDxe/ComponentName.c | 22 ++++++++++++++++++++
Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 2 +-
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.h b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.h
index b39a1326335a..26016330fb3b 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.h
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.h
@@ -235,6 +235,7 @@ typedef struct {
extern EFI_COMPONENT_NAME_PROTOCOL gGenetComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gGenetComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL mGenetDriverBinding;
extern CONST EFI_SIMPLE_NETWORK_PROTOCOL gGenetSimpleNetworkTemplate;
extern CONST EFI_ADAPTER_INFORMATION_PROTOCOL gGenetAdapterInfoTemplate;
diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/ComponentName.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/ComponentName.c
index 860e30b4da6b..abc5b7db16c2 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/ComponentName.c
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/ComponentName.c
@@ -2,6 +2,7 @@
UEFI Component Name(2) protocol implementation for GENET UEFI driver.
Copyright (c) 2020 Jared McNeill. All rights reserved.
+ Copyright (c) 2020, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -169,6 +170,27 @@ GenetComponentNameGetControllerName (
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,
+ mGenetDriverBinding.DriverBindingHandle,
+ &gEfiSimpleNetworkProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
index f9aa006dc799..435ef493564c 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
@@ -302,7 +302,7 @@ GenetDriverBindingStop (
return EFI_SUCCESS;
}
-STATIC EFI_DRIVER_BINDING_PROTOCOL mGenetDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL mGenetDriverBinding = {
GenetDriverBindingSupported,
GenetDriverBindingStart,
GenetDriverBindingStop,
--
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#64303): https://edk2.groups.io/g/devel/message/64303
Mute This Topic: https://groups.io/mt/76213603/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