Bluetooth: host: clear ATT_CONNECTED flag on detach
Clear the `ATT_CONNECTED` flag when a channel is detached (could be after an ATT timeout). Also convert the assert checking it in `chan send` to an `if` test, since the channel could be disconnected from a different thread than the one triggering `chan_send`. Fixes #53247. Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This commit is contained in:
parent
080464c7c4
commit
e6aba3e9af
1 changed files with 6 additions and 2 deletions
|
@ -216,6 +216,7 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf)
|
||||||
LOG_DBG("code 0x%02x", hdr->code);
|
LOG_DBG("code 0x%02x", hdr->code);
|
||||||
|
|
||||||
if (!atomic_test_bit(chan->flags, ATT_CONNECTED)) {
|
if (!atomic_test_bit(chan->flags, ATT_CONNECTED)) {
|
||||||
|
LOG_ERR("ATT channel not connected");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2863,8 +2864,10 @@ static struct bt_att *att_get(struct bt_conn *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
att_chan = ATT_CHAN(chan);
|
att_chan = ATT_CHAN(chan);
|
||||||
__ASSERT(atomic_test_bit(att_chan->flags, ATT_CONNECTED),
|
if (!atomic_test_bit(att_chan->flags, ATT_CONNECTED)) {
|
||||||
"ATT channel not connected");
|
LOG_ERR("ATT channel not connected");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return att_chan->att;
|
return att_chan->att;
|
||||||
}
|
}
|
||||||
|
@ -2957,6 +2960,7 @@ static void att_chan_detach(struct bt_att_chan *chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
chan->att = NULL;
|
chan->att = NULL;
|
||||||
|
atomic_clear_bit(chan->flags, ATT_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void att_timeout(struct k_work *work)
|
static void att_timeout(struct k_work *work)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue