Bluetooth: Fix memory leak with L2CAP channels
A new l2cap_chan_free() is added to free the channels.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8562ac1..338d8c3 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -160,6 +160,11 @@
return chan;
}
+void l2cap_chan_free(struct l2cap_chan *chan)
+{
+ kfree(chan);
+}
+
static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
{
struct sock *sk = chan->sk;
@@ -236,7 +241,7 @@
if (!(chan->conf_state & L2CAP_CONF_OUTPUT_DONE &&
chan->conf_state & L2CAP_CONF_INPUT_DONE))
- goto free;
+ return;
skb_queue_purge(&chan->tx_q);
@@ -255,9 +260,6 @@
kfree(l);
}
}
-
-free:
- kfree(chan);
}
static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan)