[PATCH 1/1] tools/fdt_add_pubkey: error handling in add_pubkey
Ivan Mikhaylov
fr0st61te at gmail.com
Mon Jul 31 10:16:17 CEST 2023
On Sun, 2023-07-30 at 10:15 +0200, Heinrich Schuchardt wrote:
> * 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;
Heinrich, mmap_fdt may return a lot of errors, not just ENOSPC. I don't
think that is correct.
Thanks.
>
> ret = info->crypto->add_verify_data(info, dest_blob);
> if (ret == -ENOSPC)
More information about the U-Boot
mailing list