From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.12476.1597523193518170250 for ; Sat, 15 Aug 2020 13:26:33 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: samer.el-haj-mahmoud@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CC7811B3; Sat, 15 Aug 2020 13:26:33 -0700 (PDT) Received: from U203705.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C3FE33F66B; Sat, 15 Aug 2020 13:26:32 -0700 (PDT) From: "Samer El-Haj-Mahmoud" To: devel@edk2.groups.io Cc: Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel Subject: [edk2-platform][PATCH v1 3/3] Platforms/RaspberryPi: Fix BcmGenetDxe ComponentName2 error checking Date: Sat, 15 Aug 2020 16:26:31 -0400 Message-Id: <20200815202631.29690-4-Samer.El-Haj-Mahmoud@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815202631.29690-1-Samer.El-Haj-Mahmoud@arm.com> References: <20200815202631.29690-1-Samer.El-Haj-Mahmoud@arm.com> Fix input param error checking for the BcmGenetDxe ComponentName2 protocol. This fixes https://github.com/pftf/RPi4/issues/85 Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- 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