Skip to content

Commit

Permalink
Bluetooth: L2CAP: Fix use-after-free
Browse files Browse the repository at this point in the history
Fix potential use-after-free in l2cap_le_command_rej.

Signed-off-by: Zhengping Jiang <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Zhengping Jiang authored and kuba-moo committed Jun 29, 2023
1 parent 8153b73 commit f752a0b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6374,9 +6374,14 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn,
if (!chan)
goto done;

chan = l2cap_chan_hold_unless_zero(chan);
if (!chan)
goto done;

l2cap_chan_lock(chan);
l2cap_chan_del(chan, ECONNREFUSED);
l2cap_chan_unlock(chan);
l2cap_chan_put(chan);

done:
mutex_unlock(&conn->chan_lock);
Expand Down

0 comments on commit f752a0b

Please sign in to comment.