diff mbox series

[v2,4/7] mkimage: fit_image: handle multiple errors when writing signatures

Message ID 20200421002333.111461-5-heiko@sntech.de
State Superseded
Headers show
Series rockchip: make it possible to sign the u-boot.itb | expand

Commit Message

Heiko Stuebner April 21, 2020, 12:23 a.m. UTC
From: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>

fit_image_write_sig() contains mostly functions from libfdt that
return FDT_ERR_foo errors but also a call to fit_set_timestamp()
which returns a regular error.

When handling the size increase via multiple iterations, check
for both -FDT_ERR_NOSPACE but also for -ENOSPC.

There is no real conflict, as FDT_ERR_NOSPACE = 3 = ESRCH
(No such process) and ENOSPC = 28 which is above any FDT_ERR_*.

Signed-off-by: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
 tools/image-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kever Yang April 28, 2020, 1:48 p.m. UTC | #1
On 2020/4/21 ??8:23, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>
>
> fit_image_write_sig() contains mostly functions from libfdt that
> return FDT_ERR_foo errors but also a call to fit_set_timestamp()
> which returns a regular error.
>
> When handling the size increase via multiple iterations, check
> for both -FDT_ERR_NOSPACE but also for -ENOSPC.
>
> There is no real conflict, as FDT_ERR_NOSPACE = 3 = ESRCH
> (No such process) and ENOSPC = 28 which is above any FDT_ERR_*.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>

Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> Reviewed-by: Simon Glass <sjg at chromium.org>
> ---
>   tools/image-host.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/image-host.c b/tools/image-host.c
> index 4e57ddea96..355ceb4591 100644
> --- a/tools/image-host.c
> +++ b/tools/image-host.c
> @@ -240,7 +240,7 @@ static int fit_image_process_sig(const char *keydir, void *keydest,
>   	ret = fit_image_write_sig(fit, noffset, value, value_len, comment,
>   			NULL, 0, cmdname);
>   	if (ret) {
> -		if (ret == -FDT_ERR_NOSPACE)
> +		if (ret == -FDT_ERR_NOSPACE || ret == -ENOSPC)
>   			return -ENOSPC;
>   		printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n",
>   		       node_name, image_name, fdt_strerror(ret));
diff mbox series

Patch

diff --git a/tools/image-host.c b/tools/image-host.c
index 4e57ddea96..355ceb4591 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -240,7 +240,7 @@  static int fit_image_process_sig(const char *keydir, void *keydest,
 	ret = fit_image_write_sig(fit, noffset, value, value_len, comment,
 			NULL, 0, cmdname);
 	if (ret) {
-		if (ret == -FDT_ERR_NOSPACE)
+		if (ret == -FDT_ERR_NOSPACE || ret == -ENOSPC)
 			return -ENOSPC;
 		printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n",
 		       node_name, image_name, fdt_strerror(ret));