Skip to contentSkip to conversation

imx-common: hab: fix return value from hab_auth_img

PATCH RESEND Superseded Eric Nelson 1 participant 2 messages Nov 27, 2016 – Nov 28, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 imx-common: hab: fix return value from hab_auth_img

The authenticate_image routine returns a boolean to indicate a valid (1) or invalid (0) image.

The hab_auth_img should return CMD_RET_SUCCESS to indicate success (a valid image), but currently doesn't.

Before this patch, a valid image at addres 0x12000000 with an IVT offset of 0x7a8000 will produce the following:

	=> if hab_auth_img 0x12000000 0x7a8000 ; then
	>     echo worked
	>   else
	>     echo failed
	>   fi
	Authenticate image from DDR location 0x12000000...
	Secure boot enabled
	HAB Configuration: 0xcc, HAB State: 0x99
	failed
---
 arch/arm/imx-common/hab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/imx-common/hab.c +3 -1
index 6731825..e2c04f9 100644
@@ -486,7 +486,9 @@ static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	rcode = authenticate_image(addr, ivt_offset);
 
-	return rcode;
+	return (rcode != 0)
+		? CMD_RET_SUCCESS
+		: CMD_RET_FAILURE;
 }
 
 U_BOOT_CMD(
Signature · 1 line
2.7.4
#1 lore raw

PATCH RESEND 1/1 imx-common: hab: fix return value from hab_auth_img

Hi all,

Quoted 3 lines · Eric Nelson

The authenticate_image routine returns a boolean to indicate a valid (1) or invalid (0) image.

An off-list discussion highlighted that the expected return value from the authenticate_image() routine isn't obvious since there isn't any user in main-line except the "hab_auth_img" command.

My understanding was gleaned from this use in the NXP tree:

http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/drivers/usb/gadget/f_fastboot.c?id=m6.0.1_2.1.0-ga#n1727