shell: modules: kernel: add additional check in unwind cmd
Use `shell_strtoull()` to parse the thread ID argument for error checking. Signed-off-by: Yong Cong Sin <ycsin@meta.com> Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
e3c2e8484f
commit
475fc91746
1 changed files with 6 additions and 1 deletions
|
@ -324,11 +324,16 @@ static bool print_trace_address(void *arg, unsigned long ra)
|
|||
static int cmd_kernel_thread_unwind(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
struct k_thread *thread;
|
||||
int err = 0;
|
||||
|
||||
if (argc == 1) {
|
||||
thread = _current;
|
||||
} else {
|
||||
thread = UINT_TO_POINTER(strtoll(argv[1], NULL, 16));
|
||||
thread = UINT_TO_POINTER(shell_strtoull(argv[1], 16, &err));
|
||||
if (err != 0) {
|
||||
shell_error(sh, "Unable to parse thread ID %s (err %d)", argv[1], err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!thread_is_valid(thread)) {
|
||||
shell_error(sh, "Invalid thread id %p", (void *)thread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue