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:
Peter Bigot 2020-04-05 11:43:25 -05:00 committed by Anas Nashif
commit e2e74c0f53

View file

@ -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);
}