[PATCH 09/16] efi_driver: efi_uclass: Add unbind method to efi_driver_ops

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Apr 15 14:53:09 CEST 2025


On 11.03.25 17:47, Adriano Cordova wrote:
> Signed-off-by: Adriano Cordova <adriano.cordova at canonical.com>
> ---
>   include/efi_driver.h        | 4 ++++
>   lib/efi_driver/efi_uclass.c | 4 ++++
>   2 files changed, 8 insertions(+)
> 
> diff --git a/include/efi_driver.h b/include/efi_driver.h
> index 63a95e4cf80..8f785f79459 100644
> --- a/include/efi_driver.h
> +++ b/include/efi_driver.h
> @@ -36,6 +36,8 @@ struct efi_driver_binding_extended_protocol {
>    *			driver binding protocol.
>    * @bind:		Function called by the EFI uclass to attach the
>    *			driver to EFI driver to a handle.
> + * @unbind:		Function called by the EFI uclass to detach the
> + *			driver to EFI driver to a handle.
>    */
>   struct efi_driver_ops {
>   	const efi_guid_t *protocol;
> @@ -43,6 +45,8 @@ struct efi_driver_ops {
>   	efi_status_t (*init)(struct efi_driver_binding_extended_protocol *this);
>   	efi_status_t (*bind)(struct efi_driver_binding_extended_protocol *this,
>   			     efi_handle_t handle, void *interface);
> +	efi_status_t (*unbind)(struct efi_driver_binding_extended_protocol *this,
> +			       efi_handle_t handle);
>   };
>   
>   #endif /* _EFI_DRIVER_H */
> diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
> index fc8808374a1..36a86817eb7 100644
> --- a/lib/efi_driver/efi_uclass.c
> +++ b/lib/efi_driver/efi_uclass.c
> @@ -249,6 +249,10 @@ static efi_status_t EFIAPI efi_uc_stop(
>   	if (ret != EFI_SUCCESS)
>   		log_err("Cannot free EFI memory pool\n");
>   
> +	ret = bp->ops->unbind(bp, controller_handle);

This leads to a crash as unbind() has neither been implemented for EFI 
block devices nor for EFI network devices at this point.

Please, check if unbind() is non-zero, and return EFI_DEVICE_ERROR in 
this case.

Best regards

Heinrich

> +	if (ret != EFI_SUCCESS)
> +		goto out;
> +
>   	/* Detach driver from controller */
>   	ret = efi_close_protocol(controller_handle, bp->ops->protocol,
>   				 this->driver_binding_handle,



More information about the U-Boot mailing list