ac3a84
From 1dc423e2c194eec07a04b666533cd39e74eab6de Mon Sep 17 00:00:00 2001
ac3a84
From: Jan Janssen <medhefgo@web.de>
ac3a84
Date: Sat, 12 Nov 2022 16:24:53 +0100
ac3a84
Subject: [PATCH] boot: Silence driver reconnect errors
ac3a84
ac3a84
(cherry picked from commit 98ac5192d5feddae19f6f5ceb60aa3751a30676b)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 src/boot/efi/drivers.c | 28 +++++++++++++---------------
ac3a84
 1 file changed, 13 insertions(+), 15 deletions(-)
ac3a84
ac3a84
diff --git a/src/boot/efi/drivers.c b/src/boot/efi/drivers.c
ac3a84
index 39b65e74a6..7f2057f5a1 100644
ac3a84
--- a/src/boot/efi/drivers.c
ac3a84
+++ b/src/boot/efi/drivers.c
ac3a84
@@ -51,25 +51,23 @@ static EFI_STATUS load_one_driver(
ac3a84
 }
ac3a84
 
ac3a84
 EFI_STATUS reconnect_all_drivers(void) {
ac3a84
-          _cleanup_free_ EFI_HANDLE *handles = NULL;
ac3a84
-          UINTN n_handles = 0;
ac3a84
-          EFI_STATUS err;
ac3a84
+        _cleanup_free_ EFI_HANDLE *handles = NULL;
ac3a84
+        size_t n_handles = 0;
ac3a84
+        EFI_STATUS err;
ac3a84
 
ac3a84
-          /* Reconnects all handles, so that any loaded drivers can take effect. */
ac3a84
+        /* Reconnects all handles, so that any loaded drivers can take effect. */
ac3a84
 
ac3a84
-          err = BS->LocateHandleBuffer(AllHandles, NULL, NULL, &n_handles, &handles);
ac3a84
-          if (err != EFI_SUCCESS)
ac3a84
-                  return log_error_status_stall(err, L"Failed to get list of handles: %r", err);
ac3a84
+        err = BS->LocateHandleBuffer(AllHandles, NULL, NULL, &n_handles, &handles);
ac3a84
+        if (err != EFI_SUCCESS)
ac3a84
+                return log_error_status_stall(err, L"Failed to get list of handles: %r", err);
ac3a84
 
ac3a84
-          for (UINTN i = 0; i < n_handles; i++) {
ac3a84
-                  err = BS->ConnectController(handles[i], NULL, NULL, true);
ac3a84
-                  if (err == EFI_NOT_FOUND) /* No drivers for this handle */
ac3a84
-                          continue;
ac3a84
-                  if (err != EFI_SUCCESS)
ac3a84
-                          log_error_status_stall(err, L"Failed to reconnect handle %" PRIuN L", ignoring: %r", i, err);
ac3a84
-          }
ac3a84
+        for (size_t i = 0; i < n_handles; i++)
ac3a84
+                /* Some firmware gives us some bogus handles (or they might become bad due to
ac3a84
+                 * reconnecting everything). Security policy may also prevent us from doing so too.
ac3a84
+                 * There is nothing we can realistically do on errors anyways, so just ignore them. */
ac3a84
+                (void) BS->ConnectController(handles[i], NULL, NULL, true);
ac3a84
 
ac3a84
-          return EFI_SUCCESS;
ac3a84
+        return EFI_SUCCESS;
ac3a84
 }
ac3a84
 
ac3a84
 EFI_STATUS load_drivers(