Skip to content

Commit 683d949

Browse files
Lukáš TurekGustavo F. Padovan
Lukáš Turek
authored and
Gustavo F. Padovan
committed
Bluetooth: Never deallocate a session when some DLC points to it
Fix a bug introduced in commit 9cf5b0e: function rfcomm_recv_ua calls rfcomm_session_put without checking that the session is not referenced by some DLC. If the session is freed, that DLC would refer to deallocated memory, causing an oops later, as shown in this bug report: https://bugzilla.kernel.org/show_bug.cgi?id=15994 Signed-off-by: Lukas Turek <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
1 parent e2e0cac commit 683d949

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/bluetooth/rfcomm/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
11641164
* initiator rfcomm_process_rx already calls
11651165
* rfcomm_session_put() */
11661166
if (s->sock->sk->sk_state != BT_CLOSED)
1167-
rfcomm_session_put(s);
1167+
if (list_empty(&s->dlcs))
1168+
rfcomm_session_put(s);
11681169
break;
11691170
}
11701171
}

0 commit comments

Comments
 (0)