Skip to content

Commit 9b284cb

Browse files
committed
bluetooth: fix list handling
Commit 835a6a2 ("Bluetooth: Stop sabotaging list poisoning") thought that the code was sabotaging the list poisoning when NULL'ing out the list pointers and removed it. But what was going on was that the bluetooth code was using NULL pointers for the list as a way to mark it empty, and that commit just broke it (and replaced the test with NULL with a "list_empty()" test on a uninitialized list instead, breaking things even further). So fix it all up to use the regular and real list_empty() handling (which does not use NULL, but a pointer to itself), also making sure to initialize the list properly (the previous NULL case was initialized implicitly by the session being allocated with kzalloc()) This is a combination of patches by Marcel Holtmann and Tedd Ho-Jeong An. [ I would normally expect to get this through the bt tree, but I'm going to release -rc1, so I'm just committing this directly - Linus ] Reported-and-tested-by: Jörg Otte <[email protected]> Cc: Alexey Dobriyan <[email protected]> Original-by: Tedd Ho-Jeong An <[email protected]> Original-by: Marcel Holtmann <[email protected]>: Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5c755fe commit 9b284cb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

net/bluetooth/hidp/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr,
915915
session->conn = l2cap_conn_get(conn);
916916
session->user.probe = hidp_session_probe;
917917
session->user.remove = hidp_session_remove;
918+
INIT_LIST_HEAD(&session->user.list);
918919
session->ctrl_sock = ctrl_sock;
919920
session->intr_sock = intr_sock;
920921
skb_queue_head_init(&session->ctrl_transmit);

net/bluetooth/l2cap_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user)
16341634
if (list_empty(&user->list))
16351635
goto out_unlock;
16361636

1637-
list_del(&user->list);
1637+
list_del_init(&user->list);
16381638
user->remove(conn, user);
16391639

16401640
out_unlock:
@@ -1648,7 +1648,7 @@ static void l2cap_unregister_all_users(struct l2cap_conn *conn)
16481648

16491649
while (!list_empty(&conn->users)) {
16501650
user = list_first_entry(&conn->users, struct l2cap_user, list);
1651-
list_del(&user->list);
1651+
list_del_init(&user->list);
16521652
user->remove(conn, user);
16531653
}
16541654
}

0 commit comments

Comments
 (0)