Fix input param error checking for the BcmGenetDxe ComponentName2 protocol.
This fixes https://github.com/pftf/RPi4/issues/85 Cc: Leif Lindholm <l...@nuviainc.com> Cc: Pete Batard <p...@akeo.ie> Cc: Andrei Warkentin <awarken...@vmware.com> Cc: Ard Biesheuvel <ard.biesheu...@arm.com> Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahm...@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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-