diff mbox series

efibootmgr: backport get_entry() fix to return entry once found

Message ID 20261126131920.1325879-1-hsimeliere.opensource@witekio.com
State New
Headers show
Series efibootmgr: backport get_entry() fix to return entry once found | expand

Commit Message

Hugo Simeliere Nov. 26, 2026, 1:19 p.m. UTC
From: "Hugo SIMELIERE (Schneider Electric)" <hsimeliere.opensource@witekio.com>

get_entry() does not stop when the requested entry is found and keeps
iterating over the list, overwriting the result. It only returns a
valid entry when the requested one is the last of the list.

As a consequence, every command relying on it fails for the other
entries, e.g. activating or deactivating a boot entry:

  $ efibootmgr -A -b 0005
  efibootmgr: Boot entry 5 not found
  Could not set active state for Boot0005: No such file or directory

The fix was merged upstream in 2022 but is not part of any release yet,
so backport it.

Signed-off-by: Hugo SIMELIERE (Schneider Electric) <hsimeliere.opensource@witekio.com>
---
 .../efibootmgr/0001-Update-efibootmgr.c.patch | 31 +++++++++++++++++++
 meta/recipes-bsp/efibootmgr/efibootmgr_18.bb  |  4 ++-
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-bsp/efibootmgr/efibootmgr/0001-Update-efibootmgr.c.patch
diff mbox series

Patch

diff --git a/meta/recipes-bsp/efibootmgr/efibootmgr/0001-Update-efibootmgr.c.patch b/meta/recipes-bsp/efibootmgr/efibootmgr/0001-Update-efibootmgr.c.patch
new file mode 100644
index 0000000000..6727498dd8
--- /dev/null
+++ b/meta/recipes-bsp/efibootmgr/efibootmgr/0001-Update-efibootmgr.c.patch
@@ -0,0 +1,31 @@ 
+From 6e85adb6ac0dbab5e1aefe8e262c8260f60b2cd3 Mon Sep 17 00:00:00 2001
+From: kmicki <1463619+kmicki@users.noreply.github.com>
+Date: Tue, 15 Nov 2022 14:37:25 +0100
+Subject: [PATCH] Update efibootmgr.c
+
+get_entry: return entry if it was found before reaching the end of the list
+
+Upstream-Status: Backport [https://github.com/rhboot/efibootmgr/commit/3eac27c5fccf93d2d6e634d6fe2a76d06708ec6e]
+
+Signed-off-by: kmicki <1463619+kmicki@users.noreply.github.com>
+(cherry picked from commit 3eac27c5fccf93d2d6e634d6fe2a76d06708ec6e)
+Signed-off-by: Hugo SIMELIERE (Schneider Electric) <hsimeliere.opensource@witekio.com>
+---
+ src/efibootmgr.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/efibootmgr.c b/src/efibootmgr.c
+index b980bcd..4b15d6d 100644
+--- a/src/efibootmgr.c
++++ b/src/efibootmgr.c
+@@ -1192,6 +1192,7 @@ get_entry(list_t *entries, uint16_t num)
+ 			entry = NULL;
+ 			continue;
+ 		}
++		return entry;
+ 	}
+ 
+ 	return entry;
+-- 
+2.56.1
+
diff --git a/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb b/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
index 8001496fd0..8d580830c5 100644
--- a/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
+++ b/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
@@ -10,7 +10,9 @@  DEPENDS = "efivar popt"
 
 COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux"
 
-SRC_URI = "git://github.com/rhinstaller/efibootmgr.git;protocol=https;branch=main;tag=${PV}"
+SRC_URI = "git://github.com/rhinstaller/efibootmgr.git;protocol=https;branch=main;tag=${PV} \
+           file://0001-Update-efibootmgr.c.patch \
+           "
 SRCREV = "c3f9f0534e32158f62c43564036878b93b9e0fd6"
 
 inherit pkgconfig