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

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

Add null check to avoid exception after L2CAP psm assigned

Use case: BT will get crash in SNS testing.

steps: SNS testing BT ON/OFF.

Failure: Crash is observed.

Root Cause: If the number of supported services increased,
larger service record array is required. Smaller array is
resulting in out of record error causing L2CAP deregister.

Fix: Check added to avoid null pointer exception if null
is returned while fetching sock from id. Also cleanup of
SDP and security records done during BT turning Off.

Change-Id: I2e77127262119cabf2c372f894427dcdf3350e80
parent d16ba10f
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -822,19 +822,21 @@ const tL2CAP_ERTM_INFO obex_l2c_etm_opt =
 * and this function is called with the newly allocated PSM.
 */
void on_l2cap_psm_assigned(int id, int psm) {
    l2cap_socket *sock;
    /* Setup ETM settings:
     *  mtu will be set below */
    pthread_mutex_lock(&state_lock);
    sock = btsock_l2cap_find_by_id_l(id);
    l2cap_socket *sock = btsock_l2cap_find_by_id_l(id);

    if (sock) {
        sock->channel = psm;

    if(btSock_start_l2cap_server_l(sock) != BT_STATUS_SUCCESS) {
        if (btSock_start_l2cap_server_l(sock) != BT_STATUS_SUCCESS)
            btsock_l2cap_free_l(sock);
    } else {
        APPL_TRACE_ERROR("%s: Error: sock is null", __func__);
    }

    pthread_mutex_unlock(&state_lock);

}

static bt_status_t btSock_start_l2cap_server_l(l2cap_socket *sock) {