Commit c4fbc5bb authored by Lingao Meng's avatar Lingao Meng Committed by Johan Hedberg
Browse files

Bluetooth: host: Fix hci command done



When received hci command rsp which not for expected
hci command, we should ignore this.

Signed-off-by: default avatarLingao Meng <menglingao@xiaomi.com>
parent 61370f17
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -91,16 +91,10 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
struct net_buf *bt_buf_get_cmd_complete(k_timeout_t timeout)
{
	struct net_buf *buf;
	unsigned int key;

	key = irq_lock();
	buf = bt_dev.sent_cmd;
	bt_dev.sent_cmd = NULL;
	irq_unlock(key);
	if (bt_dev.sent_cmd) {
		buf = net_buf_ref(bt_dev.sent_cmd);

	BT_DBG("sent_cmd %p", buf);

	if (buf) {
		bt_buf_set_type(buf, BT_BUF_EVT);
		buf->len = 0U;
		net_buf_reserve(buf, BT_BUF_RESERVE);
+6 −0
Original line number Diff line number Diff line
@@ -2011,6 +2011,12 @@ static void hci_cmd_done(uint16_t opcode, uint8_t status, struct net_buf *buf)
	if (cmd(buf)->opcode != opcode) {
		BT_WARN("OpCode 0x%04x completed instead of expected 0x%04x",
			opcode, cmd(buf)->opcode);
		return;
	}

	if (bt_dev.sent_cmd) {
		net_buf_unref(bt_dev.sent_cmd);
		bt_dev.sent_cmd = NULL;
	}

	if (cmd(buf)->state && !status) {