From 85a545aa55c52b92311a7eb5acfa3f982042b4df Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 2 May 2021 00:35:46 +0200 Subject: [PATCH] sx1280: avoid free ll_empty_packet --- chipset/sx128x/ll_sx1280.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/chipset/sx128x/ll_sx1280.c b/chipset/sx128x/ll_sx1280.c index 20ab9481d..4a0457eb5 100644 --- a/chipset/sx128x/ll_sx1280.c +++ b/chipset/sx128x/ll_sx1280.c @@ -590,17 +590,18 @@ static void ll_terminate(void){ // free outgoing tx packets uint8_t i; for (i=0;i<2;i++){ - if ((ctx.tx_buffer_pdu[i] != NULL) && (ctx.tx_buffer_pdu[i] != &ll_tx_packet)){ - btstack_memory_ll_pdu_free(ctx.tx_buffer_pdu[i]); + ll_pdu_t * tx_pdu = ctx.tx_buffer_pdu[i]; + if ((tx_pdu != NULL) && (tx_pdu != &ll_tx_packet) && (tx_pdu != &ll_empty_packet)){ + btstack_memory_ll_pdu_free(tx_pdu); ctx.tx_buffer_pdu[i] = NULL; } } ctx.num_tx_pdus_on_controller = 0; // free queued tx packets while (true){ - ll_pdu_t * tx_packet = (ll_pdu_t *) btstack_linked_queue_dequeue(&ctx.tx_queue); - if (tx_packet != NULL) { - btstack_memory_ll_pdu_free(tx_packet); + ll_pdu_t * tx_pdu = (ll_pdu_t *) btstack_linked_queue_dequeue(&ctx.tx_queue); + if (tx_pdu != NULL) { + btstack_memory_ll_pdu_free(tx_pdu); } else { break; }