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.web11.12719.1597523193291451517 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 B43D7101E; Sat, 15 Aug 2020 13:26:32 -0700 (PDT) Received: from U203705.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 77B743F66B; 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 2/3] Platforms/RaspberryPi: Fix DwUsbHostDxe ComponentName2 error checking Date: Sat, 15 Aug 2020 16:26:30 -0400 Message-Id: <20200815202631.29690-3-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 DwUsbHostDxe ComponentName2 protocol. This fixes https://github.com/pftf/RPi4/issues/86 Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- 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 * 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 * * 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