Skip to content

Commit 370c35e

Browse files
committed
esp32_apptrace: Fixes allocation of free data block in sync data processing mode
1 parent 46c1b70 commit 370c35e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/target/esp108_apptrace.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,13 @@ static int esp_apptrace_cmd_ctx_init(struct target *target, struct esp_apptrace_
886886

887887
cmd_ctx->running = 1;
888888

889+
res = pthread_mutex_init(&cmd_ctx->trax_blocks_mux, NULL);
890+
if (res) {
891+
LOG_ERROR("Failed to blocks pool mux (%d)!", res);
892+
esp_apptrace_blocks_pool_cleanup(cmd_ctx);
893+
return ERROR_FAIL;
894+
}
889895
if (cmd_ctx->mode != ESP_APPTRACE_CMD_MODE_SYNC) {
890-
res = pthread_mutex_init(&cmd_ctx->trax_blocks_mux, NULL);
891-
if (res) {
892-
LOG_ERROR("Failed to blocks pool mux (%d)!", res);
893-
esp_apptrace_blocks_pool_cleanup(cmd_ctx);
894-
return ERROR_FAIL;
895-
}
896896
res = pthread_create(&cmd_ctx->data_processor, NULL, esp_apptrace_data_processor, cmd_ctx);
897897
if (res) {
898898
LOG_ERROR("Failed to start trace data processor thread (%d)!", res);
@@ -927,8 +927,8 @@ static int esp_apptrace_cmd_ctx_cleanup(struct esp_apptrace_cmd_ctx *cmd_ctx)
927927
else {
928928
LOG_INFO("Trace data processor thread exited with %ld", (long)thr_res);
929929
}
930-
pthread_mutex_destroy(&cmd_ctx->trax_blocks_mux);
931930
}
931+
pthread_mutex_destroy(&cmd_ctx->trax_blocks_mux);
932932
esp_apptrace_blocks_pool_cleanup(cmd_ctx);
933933
return ERROR_OK;
934934
}

0 commit comments

Comments
 (0)