From: Ahmad Fatoum <[email protected]>

A boot script that runs, but fails, makes execute_binfmt() return its
positive exit status, while bootscript_boot() treats any non-zero value
as negative error code. A failing script thus logs nonsense:

  Running script '/env/boot/foo' failed: error -1
  Booting entry 'foo' failed: 0000000000000001

Let's print the exit status instead and return -EINVAL, so boot_entry()
and other callers get the negative error code they expect.

Fixes: 662ff5a3558e ("boot: make it a little bit less verbose")
Assisted-by: Claude:opus-5.5
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 common/boot.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/boot.c b/common/boot.c
index c7fa170224b1..00c95eb7f5f7 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -117,8 +117,13 @@ static int bootscript_boot(struct bootentry *entry, int 
verbose, int dryrun)
         * without the shell expanding or splitting it first.
         */
        ret = execute_binfmt(bs->args ? 2 : 1, argv);
-       if (ret) {
-               pr_err("Running script '%s' failed: %s\n", bs->entry.path, 
strerror(-ret));
+       if (ret > 0) {
+               pr_err("Running script '%s' failed with exit status %d\n",
+                      bs->entry.path, ret);
+               ret = -EINVAL;
+               goto out;
+       } else if (ret) {
+               pr_err("Running script '%s' failed: %pe\n", bs->entry.path, 
ERR_PTR(ret));
                goto out;
        }
 
-- 
2.47.3


Reply via email to