aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_core.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-10-10 07:33:37 -0400
committerMarcel Holtmann <marcel@holtmann.org>2013-10-10 08:00:34 -0400
commitc4e5bafa661126b7b42459ad32d4c2cc589ef8fb (patch)
treeb0647af6398962acb3532679c71221a37fc6eb6e /net/bluetooth/l2cap_core.c
parent9ecb3e24258f1ff4b9937602962ae12e3b57f98d (diff)
Bluetooth: Fix potential double-frees of L2CAP skbs
The l2cap_recv_frame function is expected to take ownership and eventually free the skb passed to it. We need to ensure that the conn->rx_skb pointer is no longer reachable when calling l2cap_recv_frame so that no other function, such as l2cap_conn_del, may think that it can free conn->rx_skb. An actual situation when this can happen is when smp_sig_channel (called from l2cap_recv_frame) fails and l2cap_conn_del gets called as a consequence. The l2cap_conn_del function would then try to free conn->rx_skb, but as the same skb was just passed to smp_sig_channel and freed we get a double-free. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r--net/bluetooth/l2cap_core.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index a9a7df6639a7..06e7173c2d13 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6798,9 +6798,13 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
6798 conn->rx_len -= skb->len; 6798 conn->rx_len -= skb->len;
6799 6799
6800 if (!conn->rx_len) { 6800 if (!conn->rx_len) {
6801 /* Complete frame received */ 6801 /* Complete frame received. l2cap_recv_frame
6802 l2cap_recv_frame(conn, conn->rx_skb); 6802 * takes ownership of the skb so set the global
6803 * rx_skb pointer to NULL first.
6804 */
6805 struct sk_buff *rx_skb = conn->rx_skb;
6803 conn->rx_skb = NULL; 6806 conn->rx_skb = NULL;
6807 l2cap_recv_frame(conn, rx_skb);
6804 } 6808 }
6805 break; 6809 break;
6806 } 6810 }