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 <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-01-28 09:59:44 +01:00 committed by Johan Hedberg
commit 576c68317a

View file

@ -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);