Skip to contentSkip to conversation

cmd: optee: fix hello subcommand argument check

PATCH In review Vincent Stehlé 3 participants 3 messages Apr 4, 2025 – Apr 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: optee: fix hello subcommand argument check

When the `optee hello' subcommand is called, the do_optee_hello_world_ta() function passes a NULL pointer to the strcmp() function while verifying its input argument, which results in the following crash:

=> optee hello
"Synchronous Abort" handler, esr 0x96000010, far 0x0

Fix this by verifying the number of input arguments instead.

Fixes e3cf80fbe02d ("cmd: Add support for optee commands")
Cc Jens Wiklander <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Tom Rini <[email protected]>
Cc Jerome Forissier <[email protected]>
Cc Venkatesh Yadav Abbarapu <[email protected]>
---
 cmd/optee.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/optee.c +1 -1
index d0d37293986..e3aae5e9f9b 100644
@@ -53,7 +53,7 @@ static int do_optee_hello_world_ta(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	int ret, value = 0;
 
-	if (strcmp(argv[1], NULL))
+	if (argc > 1)
 		value = hextoul(argv[1], NULL);
 
 	ret = hello_world_ta(value);
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Vincent Stehlé

When the `optee hello' subcommand is called, the do_optee_hello_world_ta() function passes a NULL pointer to the strcmp() function while verifying its input argument, which results in the following crash:

=> optee hello
"Synchronous Abort" handler, esr 0x96000010, far 0x0

Fix this by verifying the number of input arguments instead.

Fixes e3cf80fbe02d ("cmd: Add support for optee commands")
Cc Jens Wiklander <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Tom Rini <[email protected]>
Cc Jerome Forissier <[email protected]>
Cc Venkatesh Yadav Abbarapu <[email protected]>
---
 cmd/optee.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/optee.c +0 -0
index d0d37293986..e3aae5e9f9b 100644

cmd/optee.c static int do_optee_hello_world_ta(struct cmd_tbl *cmdtp, int flag, int argc, · line 59

Quoted 8 lines
cmd/optee.c +1 -1
@@ -53,7 +53,7 @@ static int do_optee_hello_world_ta(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	int ret, value = 0;
 
-	if (strcmp(argv[1], NULL))
+	if (argc > 1)
 		value = hextoul(argv[1], NULL);
 
 	ret = hello_world_ta(value);

How did I miss that? :O Anyways...

Thanks!

Signature · 1 line
Jerome
#2 lore raw
In reply to Vincent Stehlé
Quoted 8 lines · Vincent Stehlé

When the `optee hello' subcommand is called, the do_optee_hello_world_ta() function passes a NULL pointer to the strcmp() function while verifying its input argument, which results in the following crash:

=> optee hello
"Synchronous Abort" handler, esr 0x96000010, far 0x0

[...]

Applied to u-boot/master, thanks!

[1/1] cmd: optee: fix hello subcommand argument check

      commit: c4b273e441327f74449b3035d61ea92a077c1baa
Signature · 1 line
Tom