@@ -1343,10 +1343,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)I think this patch does not make sense Because inside chan->ops->close() "chan" could be freed in the l2cap_chan_destroy().
l2cap_chan_lock(chan);
l2cap_chan_del(chan, err);
+ chan->ops->close(chan->data);
l2cap_chan_unlock(chan);
- chan->ops->close(chan->data);
l2cap_chan_put(chan);
}
close callback must locate within chan_lock unless it can be scheduled to other threadEven l2cap_sock_kill() is called twice, " if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)" can't filter it.
which may wait for chan_lock in l2cap_sock_shutdown and this lead to duplicate sock_kill.
static void l2cap_sock_kill(struct sock *sk)
{
- if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
+ if (!sock_flag(sk, SOCK_ZAPPED) || sock_flag(sk, SOCK_DEAD) ||
+ sk->sk_socket)
return;
BT_DBG("sk %p state %s", sk, state_to_string(sk->sk_state));
Duplicate sock_kill may happen anyway, need test SOCK_DEAD if chan_destroy is already called.