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

Commit a136d67a authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by Andre Eisenbach
Browse files

Add a log message to capture NULL pointer in l2c_link_hci_disc_comp()

Added a log message inside l2c_link_hci_disc_comp() to help capture
a NULL pointer p_lcb->p_fixed_ccbs[xx] that triggers SIGSEGV crash.
Also, updated the typedef of bdstr_t and moved it to
file "btcore/include/bdaddr.h"

Bug: 28765514
Change-Id: Iacd9376cfb9e18b58e18865581da8edad9f68821
parent 9250f02d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include "bta_gattc_int.h"
#include "bta_sys.h"
#include "btcore/include/bdaddr.h"
#include "btif/include/btif_util.h"
#include "bt_common.h"
#include "l2c_api.h"
#include "utl.h"
+3 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ extern "C" {
// both uppercase and lowercase digits but will only ever produce lowercase
// digits.

typedef char bdstr_t[sizeof("xx:xx:xx:xx:xx:xx")];

// Returns true if |addr| is the empty address (00:00:00:00:00:00).
// |addr| may not be NULL.
bool bdaddr_is_empty(const bt_bdaddr_t *addr);
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "bta_hh_api.h"
#include "btif_util.h"
#include "bta_hh_co.h"
#include "btcore/include/bdaddr.h"

const char *dev_path = "/dev/uhid";

+0 −3
Original line number Diff line number Diff line
@@ -43,9 +43,6 @@ extern "C" {
**  Type definitions for callback functions
********************************************************************************/

typedef char bdstr_t[18];


/*******************************************************************************
**  Functions
********************************************************************************/
+16 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 *
 ******************************************************************************/

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -39,6 +40,7 @@
#include "btu.h"
#include "btm_api.h"
#include "btm_int.h"
#include "btcore/include/bdaddr.h"


extern fixed_queue_t *btu_general_alarm_queue;
@@ -465,6 +467,19 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
                  (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
                          p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR);
#endif
                    if (p_lcb->p_fixed_ccbs[xx] == NULL) {
                      bdstr_t bd_addr_str = {0};
                      L2CAP_TRACE_ERROR("%s: unexpected p_fixed_ccbs[%d] is NULL remote_bd_addr = %s p_lcb = %p in_use = %d link_state = %d handle = %d link_role = %d is_bonding = %d disc_reason = %d transport = %d",
                                        __func__, xx,
                                        bdaddr_to_string((bt_bdaddr_t *)&p_lcb->remote_bd_addr,
                                                         bd_addr_str,
                                                         sizeof(bd_addr_str)),
                                        p_lcb, p_lcb->in_use,
                                        p_lcb->link_state, p_lcb->handle,
                                        p_lcb->link_role, p_lcb->is_bonding,
                                        p_lcb->disc_reason, p_lcb->transport);
                    }
                    assert(p_lcb->p_fixed_ccbs[xx] != NULL);
                    l2cu_release_ccb (p_lcb->p_fixed_ccbs[xx]);

                    p_lcb->p_fixed_ccbs[xx] = NULL;