[PATCH 1/4] commands: hab: check for error in imx_hab_device_locked_down

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jul 26 12:27:15 PDT 2023


imx_hab_device_locked_down() reads efuses and that operation can fail.
Instead of assuming a failure means the efuses are non-zero, have the
hab command explicitly check for negative error codes.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/hab.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/commands/hab.c b/commands/hab.c
index 97a1701fa551..8ae943a4c880 100644
--- a/commands/hab.c
+++ b/commands/hab.c
@@ -58,7 +58,13 @@ static int do_hab(int argc, char *argv[])
 			printf("%02x", srk[i]);
 		printf("\n");
 
-		if (imx_hab_device_locked_down())
+		ret = imx_hab_device_locked_down();
+		if (ret < 0) {
+			printf("failed to determine lockdown mode: '%pe'\n", ERR_PTR(ret));
+			return ret;
+		}
+
+		if (ret)
 			printf("secure mode\n");
 		else
 			printf("devel mode\n");
-- 
2.39.2




More information about the barebox mailing list