From ba64c39c8caa2f04f3d78765b48d661b7e9d19ee Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Thu, 16 Jun 2016 16:37:57 -0700 Subject: [PATCH] Add missing NULL pointers assignments Each pointer that was freed by one of the following functions should be reset to NULL: - config_free() - data_dispatcher_free() - fixed_queue_free() - list_free() Bug: 29421693 Change-Id: Ie55a04ed986393994564edcf872d7413b0767a85 (cherry picked from commit 8cbc291080730cd7d04990a8fc0e11249b06aa08) --- btif/src/btif_hl.c | 1 + btif/src/btif_sock_rfc.c | 1 + hci/src/hci_layer.c | 2 ++ main/stack_config.c | 1 + stack/gatt/gatt_utils.c | 1 + stack/l2cap/l2c_main.c | 1 + stack/l2cap/l2c_utils.c | 1 + stack/rfcomm/port_utils.c | 2 ++ 8 files changed, 10 insertions(+) diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c index d3cf6b2d6..eec9d3449 100644 --- a/btif/src/btif_hl.c +++ b/btif/src/btif_hl.c @@ -4768,6 +4768,7 @@ static inline int btif_hl_close_select_thread(void) } } list_free(soc_queue); + soc_queue = NULL; return (int)result; } diff --git a/btif/src/btif_sock_rfc.c b/btif/src/btif_sock_rfc.c index e92c826e3..0a971fdd6 100644 --- a/btif/src/btif_sock_rfc.c +++ b/btif/src/btif_sock_rfc.c @@ -135,6 +135,7 @@ void btsock_rfc_cleanup(void) { if (rfc_slots[i].id) cleanup_rfc_slot(&rfc_slots[i]); list_free(rfc_slots[i].incoming_queue); + rfc_slots[i].incoming_queue = NULL; } pthread_mutex_unlock(&slot_lock); } diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c index a30f8c4f1..d566141fc 100644 --- a/hci/src/hci_layer.c +++ b/hci/src/hci_layer.c @@ -299,6 +299,7 @@ static future_t *shut_down() { fixed_queue_free(packet_queue, buffer_allocator->free); packet_queue = NULL; list_free(commands_pending_response); + commands_pending_response = NULL; pthread_mutex_destroy(&commands_pending_response_lock); @@ -802,6 +803,7 @@ void hci_layer_cleanup_interface() { interface.do_postload = NULL; data_dispatcher_free(interface.event_dispatcher); + interface.event_dispatcher = NULL; interface.set_data_queue = NULL; interface.transmit_command = NULL; diff --git a/main/stack_config.c b/main/stack_config.c index 1f4f00fac..109042f27 100644 --- a/main/stack_config.c +++ b/main/stack_config.c @@ -61,6 +61,7 @@ static future_t *init() { static future_t *clean_up() { config_free(config); + config = NULL; return future_new_immediate(FUTURE_SUCCESS); } diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c index 0f722ccf2..f56925d74 100644 --- a/stack/gatt/gatt_utils.c +++ b/stack/gatt/gatt_utils.c @@ -2285,6 +2285,7 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport) gatt_free_pending_ind(p_tcb); gatt_free_pending_enc_queue(p_tcb); fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL); + p_tcb->sr_cmd.multi_rsp_q = NULL; for (i = 0; i < GATT_MAX_APPS; i ++) { diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index ad1e583d7..dab56a24d 100644 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -858,6 +858,7 @@ void l2c_init (void) void l2c_free(void) { list_free(l2cb.rcv_pending_q); + l2cb.rcv_pending_q = NULL; } void l2c_receive_hold_timer_timeout(UNUSED_ATTR void *data) diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c index ff6461f7d..58ac4b06b 100644 --- a/stack/l2cap/l2c_utils.c +++ b/stack/l2cap/l2c_utils.c @@ -264,6 +264,7 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb) osi_free(p_buf); } fixed_queue_free(p_lcb->le_sec_pending_q, NULL); + p_lcb->le_sec_pending_q = NULL; } } diff --git a/stack/rfcomm/port_utils.c b/stack/rfcomm/port_utils.c index e23965fe5..3a8ff6c8c 100644 --- a/stack/rfcomm/port_utils.c +++ b/stack/rfcomm/port_utils.c @@ -240,7 +240,9 @@ void port_release_port(tPORT *p_port) rfc_port_timer_stop (p_port); fixed_queue_free(p_port->tx.queue, NULL); + p_port->tx.queue = NULL; fixed_queue_free(p_port->rx.queue, NULL); + p_port->rx.queue = NULL; if (p_port->keep_port_handle) { -- 2.11.0