Skip to content

Commit 835a6a2

Browse files
Alexey Dobriyanholtmann
authored andcommitted
Bluetooth: Stop sabotaging list poisoning
list_del() poisons pointers with special values, no need to overwrite them. Signed-off-by: Alexey Dobriyan <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent d446278 commit 835a6a2

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user)
16011601

16021602
hci_dev_lock(hdev);
16031603

1604-
if (user->list.next || user->list.prev) {
1604+
if (!list_empty(&user->list)) {
16051605
ret = -EINVAL;
16061606
goto out_unlock;
16071607
}
@@ -1631,12 +1631,10 @@ void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user)
16311631

16321632
hci_dev_lock(hdev);
16331633

1634-
if (!user->list.next || !user->list.prev)
1634+
if (list_empty(&user->list))
16351635
goto out_unlock;
16361636

16371637
list_del(&user->list);
1638-
user->list.next = NULL;
1639-
user->list.prev = NULL;
16401638
user->remove(conn, user);
16411639

16421640
out_unlock:
@@ -1651,8 +1649,6 @@ static void l2cap_unregister_all_users(struct l2cap_conn *conn)
16511649
while (!list_empty(&conn->users)) {
16521650
user = list_first_entry(&conn->users, struct l2cap_user, list);
16531651
list_del(&user->list);
1654-
user->list.next = NULL;
1655-
user->list.prev = NULL;
16561652
user->remove(conn, user);
16571653
}
16581654
}

0 commit comments

Comments
 (0)