Commit 334369ab authored by Joakim Andersson's avatar Joakim Andersson Committed by Christopher Friedt
Browse files

Bluetooth: host: Fix dereference before null check



Fix dereference before null check in att.c

Fixes: #37947

Signed-off-by: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
parent 2e9f6d02
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2882,14 +2882,17 @@ int bt_eatt_connect(struct bt_conn *conn, uint8_t num_channels)

int bt_eatt_disconnect(struct bt_conn *conn)
{
	struct bt_att_chan *chan = att_get_fixed_chan(conn);
	struct bt_att *att = chan->att;
	struct bt_att_chan *chan;
	struct bt_att *att;
	int err = -ENOTCONN;

	if (!conn) {
		return -EINVAL;
	}

	chan = att_get_fixed_chan(conn);
	att = chan->att;

	SYS_SLIST_FOR_EACH_CONTAINER(&att->chans, chan, node) {
		if (atomic_test_bit(chan->flags, ATT_ENHANCED)) {
			err = bt_l2cap_chan_disconnect(&chan->chan.chan);