Skip to contentSkip to conversation

bluetooth: stop sabotaging list poisoning

PATCH In review Alexey Dobriyan 2 participants 2 messages Jun 10, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bluetooth: stop sabotaging list poisoning

list_del() poisons pointers with special values, no need to overwrite them.

---

 net/bluetooth/l2cap_core.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/bluetooth/l2cap_core.c +2 -6
@@ -1601,7 +1601,7 @@ int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user)
 
 	hci_dev_lock(hdev);
 
-	if (user->list.next || user->list.prev) {
+	if (!list_empty(&user->list)) {
 		ret = -EINVAL;
 		goto out_unlock;
 	}
@@ -1631,12 +1631,10 @@ void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user)
 
 	hci_dev_lock(hdev);
 
-	if (!user->list.next || !user->list.prev)
+	if (list_empty(&user->list))
 		goto out_unlock;
 
 	list_del(&user->list);
-	user->list.next = NULL;
-	user->list.prev = NULL;
 	user->remove(conn, user);
 
 out_unlock:
@@ -1651,8 +1649,6 @@ static void l2cap_unregister_all_users(struct l2cap_conn *conn)
 	while (!list_empty(&conn->users)) {
 		user = list_first_entry(&conn->users, struct l2cap_user, list);
 		list_del(&user->list);
-		user->list.next = NULL;
-		user->list.prev = NULL;
 		user->remove(conn, user);
 	}
 }
maintainer
#1 lore raw

Hi Alexey,

Quoted 7 lines

list_del() poisons pointers with special values, no need to overwrite them.

---

net/bluetooth/l2cap_core.c | 8 ++------

1 file changed, 2 insertions(+), 6 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel