shell: fix return after taking lock
Check for error conditions before locking a mutex. See https://habr.com/en/company/pvs-studio/blog/495284/ fragment 16. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
55daa79ba3
commit
e2e74c0f53
1 changed files with 2 additions and 2 deletions
|
@ -1186,14 +1186,14 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
|
|||
err = k_poll(shell->ctx->events, SHELL_SIGNAL_TXDONE,
|
||||
K_FOREVER);
|
||||
|
||||
k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
|
||||
|
||||
if (err != 0) {
|
||||
shell_internal_fprintf(shell, SHELL_ERROR,
|
||||
"Shell thread error: %d", err);
|
||||
return;
|
||||
}
|
||||
|
||||
k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
|
||||
|
||||
if (shell->iface->api->update) {
|
||||
shell->iface->api->update(shell->iface);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue