[PATCH 02/16] efi_loader: efi_net: check efi_search_protocol return value
Ilias Apalodimas
ilias.apalodimas at linaro.org
Sat Apr 12 09:29:10 CEST 2025
Hi Adriano
Apologies for the very late review, I was travelling a lot...
On Tue, 11 Mar 2025 at 18:47, Adriano Cordova <adrianox at gmail.com> wrote:
>
You need a proper commit message on why we need this
> Signed-off-by: Adriano Cordova <adriano.cordova at canonical.com>
> ---
> lib/efi_loader/efi_net.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
> index 0334eedaf5c..8c0a3f5243c 100644
> --- a/lib/efi_loader/efi_net.c
> +++ b/lib/efi_loader/efi_net.c
> @@ -1020,7 +1020,9 @@ efi_status_t efi_netobj_set_dp(struct efi_net_obj *netobj, struct efi_device_pat
> return EFI_OUT_OF_RESOURCES;
>
> phandler = NULL;
> - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + ret = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
> + return ret;
>
> // If the device path protocol is not yet installed, install it
> if (!phandler)
> @@ -1051,12 +1053,15 @@ add:
> static struct efi_device_path *efi_netobj_get_dp(struct efi_net_obj *netobj)
> {
> struct efi_handler *phandler;
> + efi_status_t r;
>
> if (!efi_netobj_is_active(netobj))
> return NULL;
>
> phandler = NULL;
> - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + r = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + if (r != EFI_SUCCESS && r != EFI_NOT_FOUND)
Why do you check for EFI_NOT_FOUND here? If the protocol isn't
installed it will just fail adn retunr NULL a few lines below
> + return NULL;
>
> if (phandler && phandler->protocol_interface)
> return efi_dp_dup(phandler->protocol_interface);
> @@ -1444,7 +1449,9 @@ int efi_net_unregister(void *ctx, struct event *event)
> return -1;
>
> phandler = NULL;
> - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + ret = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler);
> + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
same here
> + return -1;
> if (phandler && phandler->protocol_interface)
> interface = phandler->protocol_interface;
>
> --
> 2.48.1
>
Cheers
/Ilias
More information about the U-Boot
mailing list