[PATCH 1/1] tools/fdt_add_pubkey: error handling in add_pubkey
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sun Jul 30 10:15:33 CEST 2023
* If info is NULL, do not dereference it.
* If mmap fails, print an error message.
Fixes: 30238e99619c ("tools: add fdt_add_pubkey")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
tools/fdt_add_pubkey.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/fdt_add_pubkey.c b/tools/fdt_add_pubkey.c
index 5582d7a8ef..7843a006f0 100644
--- a/tools/fdt_add_pubkey.c
+++ b/tools/fdt_add_pubkey.c
@@ -89,8 +89,10 @@ static int add_pubkey(struct image_sign_info *info)
struct stat dest_sbuf;
size_t size_inc = 0;
- if (!info)
+ if (!info) {
fprintf(stderr, "Error: info is NULL in %s\n", __func__);
+ return -EINVAL;
+ }
do {
if (destfd >= 0) {
@@ -104,7 +106,7 @@ static int add_pubkey(struct image_sign_info *info)
destfd = mmap_fdt(cmdname, keydest, size_inc, &dest_blob,
&dest_sbuf, false, false);
if (destfd < 0)
- exit(EXIT_FAILURE);
+ return -ENOSPC;
ret = info->crypto->add_verify_data(info, dest_blob);
if (ret == -ENOSPC)
--
2.40.1
More information about the U-Boot
mailing list