Signed-off-by: Adriano Cordova <adriano.cord...@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)
+               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)
+                       return -1;
                if (phandler && phandler->protocol_interface)
                        interface = phandler->protocol_interface;
 
-- 
2.48.1

Reply via email to