|
| 1 | +From 1c76d1d65e6da0a63b8bc9329debcf2ff1516143 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io> |
| 3 | +Date: Mon, 30 Mar 2026 11:40:28 +0200 |
| 4 | +Subject: [PATCH] Fix use-before-init in ldacBT_init_handle_decode |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +ldacBT_close_handle() resets cci/frmlen/frm_status to UNSET (-1). |
| 10 | +The subsequent ldaclib_set_config_info() was called with these stale |
| 11 | +struct members instead of the freshly computed local values, causing |
| 12 | +LDAC_ERR_ASSERT_CHANNEL_CONFIG (533) on every invocation regardless |
| 13 | +of the channel mode passed in. |
| 14 | + |
| 15 | +Move the struct assignments before the ldaclib_set_config_info() call |
| 16 | +so it receives valid configuration. |
| 17 | + |
| 18 | +This was breaking LDAC A2DP in PipeWire: the decoder handle fails to |
| 19 | +initialise during codec_init(), which aborts the entire codec setup |
| 20 | +and leaves the bluetooth sink unable to start. |
| 21 | + |
| 22 | +Signed-off-by: Jörg Thalheim <joerg@thalheim.io> |
| 23 | +--- |
| 24 | + src/ldacBT_api.o.c | 9 ++++----- |
| 25 | + 1 file changed, 4 insertions(+), 5 deletions(-) |
| 26 | + |
| 27 | +diff --git a/src/ldacBT_api.o.c b/src/ldacBT_api.o.c |
| 28 | +index f4cb9cd..a396a14 100644 |
| 29 | +--- a/src/ldacBT_api.o.c |
| 30 | ++++ b/src/ldacBT_api.o.c |
| 31 | +@@ -165,6 +165,10 @@ LDACBT_API int ldacBT_init_handle_decode( |
| 32 | + // tbl_ldacbt_config[0].frmlen_1ch; |
| 33 | + // frmlen = 165 * channel - LDACBT_FRMHDRBYTES; |
| 34 | + frmlen = tbl_ldacbt_config[0].frmlen_1ch * channel - LDACBT_FRMHDRBYTES; |
| 35 | ++ hLdacBT->frmlen = frmlen; |
| 36 | ++ hLdacBT->cm = cm; |
| 37 | ++ hLdacBT->cci = cci; |
| 38 | ++ hLdacBT->frm_status = 0; |
| 39 | + /* Set Configuration Information */ |
| 40 | + result = ldaclib_set_config_info( |
| 41 | + hLdacBT->hLDAC, hLdacBT->sfid, hLdacBT->cci, hLdacBT->frmlen, hLdacBT->frm_status); |
| 42 | +@@ -174,11 +178,6 @@ LDACBT_API int ldacBT_init_handle_decode( |
| 43 | + } else if (result != LDAC_S_OK) { |
| 44 | + hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE; |
| 45 | + } |
| 46 | +- hLdacBT->frmlen = frmlen; |
| 47 | +- hLdacBT->cm = cm; |
| 48 | +- hLdacBT->cci = cci; |
| 49 | +- hLdacBT->frm_status = 0; |
| 50 | +- hLdacBT->sfid = sfid; |
| 51 | + result = ldaclib_init_decode(hLdacBT->hLDAC, nshift); |
| 52 | + if (LDAC_FAILED(result)) { |
| 53 | + hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE; |
| 54 | +-- |
| 55 | +2.53.0 |
| 56 | + |
0 commit comments