All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_conn_failed: Fixes memory leak
@ 2023-10-07 11:39 ` Yuran Pereira
  0 siblings, 0 replies; 10+ messages in thread
From: Yuran Pereira @ 2023-10-07 11:39 UTC (permalink / raw)
  To: marcel
  Cc: Yuran Pereira, johan.hedberg, luiz.dentz, linux-bluetooth,
	linux-kernel, linux-kernel-mentees, syzbot+39ec16ff6cc18b1d066d

The hci_conn_failed() function currently calls hci_connect_cfm(), which
indirectly leads to the allocation of an l2cap_conn struct in l2cap_conn_add().
This operation results in a memory leak, as the l2cap_conn structure
becomes unreferenced.

To address this issue and prevent the memory leak, this patch modifies
hci_conn_failed() to replace the call to hci_connect_cfm() with a
call to hci_disconn_cfm().

Reported-by: syzbot+39ec16ff6cc18b1d066d@syzkaller.appspotmail.com
Signed-off-by: Yuran Pereira <yuran.pereira@hotmail.com>
---
 net/bluetooth/hci_conn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 7a6f20338db8..1d2d03b4a98a 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1248,7 +1248,7 @@ void hci_conn_failed(struct hci_conn *conn, u8 status)
 	}
 
 	conn->state = BT_CLOSED;
-	hci_connect_cfm(conn, status);
+	hci_disconn_cfm(conn, status);
 	hci_conn_del(conn);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-10 14:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-07 11:39 [PATCH] Bluetooth: hci_conn_failed: Fixes memory leak Yuran Pereira
2023-10-07 11:39 ` Yuran Pereira
2023-10-07 11:41 ` Greg KH
2023-10-07 11:41   ` Greg KH
2023-10-07 17:39   ` Yuran Pereira
2023-10-09 19:50     ` Luiz Augusto von Dentz
2023-10-09 19:50       ` Luiz Augusto von Dentz
2023-10-10 14:43       ` Yuran Pereira
2023-10-10 14:43         ` Yuran Pereira
2023-10-07 12:18 ` bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.