diff mbox series

[4/5] efi_loader: fix the return codes of UninstallProtocol

Message ID 20230615143941.416924-4-ilias.apalodimas@linaro.org
State Superseded
Headers show
Series [1/5] efi_loader: check the status of disconnected drivers | expand

Commit Message

Ilias Apalodimas June 15, 2023, 2:39 p.m. UTC
Up to now we did not check the return value of DisconnectController.
A previous patch is fixing that taking into account what happened during
the controller disconnect.  But that check takes place before our code
is trying to figure out if the interface exists to begin with.  In case a
driver is not allowed to unbind -- e.g returning EFI_DEVICE_ERROR, we
will end up returning that error instead of EFI_NOT_FOUND.

Add an extra check on the top of the function to make sure the protocol
interface exists before trying to disconnect any drivers

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_boottime.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Heinrich Schuchardt June 18, 2023, 7:08 a.m. UTC | #1
On 6/15/23 16:39, Ilias Apalodimas wrote:
> Up to now we did not check the return value of DisconnectController.
> A previous patch is fixing that taking into account what happened during
> the controller disconnect.  But that check takes place before our code
> is trying to figure out if the interface exists to begin with.  In case a
> driver is not allowed to unbind -- e.g returning EFI_DEVICE_ERROR, we
> will end up returning that error instead of EFI_NOT_FOUND.
>
> Add an extra check on the top of the function to make sure the protocol
> interface exists before trying to disconnect any drivers
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   lib/efi_loader/efi_boottime.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index b148824c7ec5..d6d52d4bbac8 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1373,6 +1373,8 @@ static efi_status_t efi_uninstall_protocol
>   	r = efi_search_protocol(handle, protocol, &handler);
>   	if (r != EFI_SUCCESS)
>   		goto out;
> +	if (handler->protocol_interface != protocol_interface)
> +		return EFI_NOT_FOUND;
>   	/* Disconnect controllers */
>   	r = efi_disconnect_all_drivers(handle, NULL, NULL);
>   	if (r != EFI_SUCCESS) {
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b148824c7ec5..d6d52d4bbac8 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1373,6 +1373,8 @@  static efi_status_t efi_uninstall_protocol
 	r = efi_search_protocol(handle, protocol, &handler);
 	if (r != EFI_SUCCESS)
 		goto out;
+	if (handler->protocol_interface != protocol_interface)
+		return EFI_NOT_FOUND;
 	/* Disconnect controllers */
 	r = efi_disconnect_all_drivers(handle, NULL, NULL);
 	if (r != EFI_SUCCESS) {