From 576c68317a93897ecea1a549103855c2ca4464d8 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Tue, 28 Jan 2020 09:59:44 +0100 Subject: [PATCH] Bluetooth: L2CAP: Reset channel status before destroy callback Move reset of channel status from after the destroy callback since the after the destroy callback the memory should be assumed to be released. Instead clear the channel status when the channel is created in l2cap_chan_add. This way we don't rely on the memory given being set to the correct value. Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/l2cap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 4dba4257695..526546c8c17 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -257,7 +257,6 @@ destroy: chan->destroy(chan); } - atomic_clear(chan->status); } static void l2cap_rtx_timeout(struct k_work *work) @@ -315,6 +314,7 @@ static bool l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, } k_delayed_work_init(&chan->rtx_work, l2cap_rtx_timeout); + atomic_clear(chan->status); bt_l2cap_chan_add(conn, chan, destroy);