Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9048eddf authored by Gurpreet Ghai's avatar Gurpreet Ghai Committed by Myles Watson
Browse files

BTE: Allocate LogMsg buffer on the stack

Problem:
Due to static 1k buffer in LogMsg function is leading to a crash in
btapp as this function is called from multiple threads

Steps:
A2DP streaming or similar process that performs excessive logging

Failure: Crash occurs

Root Cause:
Static buffer being accessed and updated by different threads parallelly

Fix:
Used local buffer instead of static buffer from LogMsg function

Test: manual
Fixes: 69586278
Change-Id: I037d85c1ca0e134d1fa86308d0467f88d8ea159d
parent 911de1a5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@
#endif

#ifndef BTE_LOG_BUF_SIZE
#define BTE_LOG_BUF_SIZE 1024
#define BTE_LOG_BUF_SIZE 256
#endif

#define BTE_LOG_MAX_SIZE (BTE_LOG_BUF_SIZE - 12)
@@ -132,7 +132,7 @@ static tBTTRC_FUNC_MAP bttrc_set_level_map[] = {
    {0, 0, NULL, NULL, DEFAULT_CONF_TRACE_LEVEL}};

void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {
  static char buffer[BTE_LOG_BUF_SIZE];
  char buffer[BTE_LOG_BUF_SIZE];
  int trace_layer = TRACE_GET_LAYER(trace_set_mask);
  if (trace_layer >= TRACE_LAYER_MAX_NUM) trace_layer = 0;