mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/5] bootm: fix error reporting around optee_verify_header_request_region
@ 2025-04-16 10:37 Ahmad Fatoum
  2025-04-16 10:37 ` [PATCH 2/5] treewide: replace strerror of errno with %m Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-04-16 10:37 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-16 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16 10:37 [PATCH 1/5] bootm: fix error reporting around optee_verify_header_request_region Ahmad Fatoum
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox