mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/5] bootm: fix error reporting around optee_verify_header_request_region
Date: Wed, 16 Apr 2025 12:37:44 +0200	[thread overview]
Message-ID: <20250416103748.265415-1-a.fatoum@pengutronix.de> (raw)

optee_verify_header_request_region doesn't set errno, so printing it out
and setting ret to -errno is wrong.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/lib32/bootm.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index 625091ece1e9..34ce401e8fd9 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -152,21 +152,23 @@ static int get_kernel_addresses(size_t image_size,
 
 static int optee_verify_header_request_region(struct image_data *data, struct optee_header *hdr)
 {
-	int ret = 0;
+	int ret;
 
 	ret = optee_verify_header(hdr);
-	if (ret < 0)
+	if (ret < 0) {
+		pr_err("Could not verify header: %pe", ERR_PTR(ret));
 		return ret;
+	}
 
 	data->tee_res = request_sdram_region("TEE", hdr->init_load_addr_lo, hdr->init_size);
 	if (!data->tee_res) {
-		pr_err("Cannot request SDRAM region 0x%08x-0x%08x: %s\n",
+		pr_err("Cannot request SDRAM region 0x%08x-0x%08x: %pe\n",
 		       hdr->init_load_addr_lo, hdr->init_load_addr_lo + hdr->init_size - 1,
-		       strerror(-EINVAL));
+		       ERR_PTR(-EINVAL));
 		return -EINVAL;
 	}
 
-	return ret;
+	return 0;
 }
 
 static int bootm_load_tee_from_fit(struct image_data *data)
@@ -186,11 +188,9 @@ static int bootm_load_tee_from_fit(struct image_data *data)
 			return ret;
 		}
 		memcpy(&hdr, tee, sizeof(hdr));
-		if (optee_verify_header_request_region(data, &hdr) < 0) {
-			pr_err("%s", strerror(errno));
-			ret = -errno;
+		ret = optee_verify_header_request_region(data, &hdr);
+		if (ret < 0)
 			goto out;
-		}
 		memcpy((void *)data->tee_res->start, tee + sizeof(hdr), hdr.init_size);
 		printf("Read optee image to %pa, size 0x%08x\n", (void *)data->tee_res->start, hdr.init_size);
 	}
@@ -214,11 +214,9 @@ static int bootm_load_tee_from_file(struct image_data *data)
 		goto out;
 	}
 
-	if (optee_verify_header_request_region(data, &hdr) < 0) {
-		pr_err("%s", strerror(errno));
-		ret = -errno;
+	ret = optee_verify_header_request_region(data, &hdr);
+	if (ret < 0)
 		goto out;
-	}
 
 	if (read_full(fd, (void *)data->tee_res->start, hdr.init_size) < 0) {
 		pr_err("%s", strerror(errno));
-- 
2.39.5




             reply	other threads:[~2025-04-16 10:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 10:37 Ahmad Fatoum [this message]
2025-04-16 10:37 ` [PATCH 2/5] treewide: replace strerror of errno with %m Ahmad Fatoum
2025-04-16 10:37 ` [PATCH 3/5] commands: memtester: fix erroneous use of errno Ahmad Fatoum
2025-04-16 10:37 ` [PATCH 4/5] treewide: fix wrong signed value passed to strerror Ahmad Fatoum
2025-04-16 10:37 ` [PATCH 5/5] treewide: replace strerror with %pe format specifier Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416103748.265415-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox