Bluetooth: Fix removing adv when processing cmd complete
authorArchie Pusaka <apusaka@chromium.org>
Thu, 28 Oct 2021 11:17:25 +0000 (19:17 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:22 +0000 (11:04 +0100)
commit41966cae91f1446449fba546f870e62eb39904aa
tree0f454d513218f847222a72382e03daacaa435d3b
parent57347363de0bc55adb5dbb3f2f5739f3f38d9b63
Bluetooth: Fix removing adv when processing cmd complete

[ Upstream commit 2128939fe2e771645dd88e1938c27fdf96bd1cd0 ]

If we remove one instance of adv using Set Extended Adv Enable, there
is a possibility of issue occurs when processing the Command Complete
event. Especially, the adv_info might not be found since we already
remove it in hci_req_clear_adv_instance() -> hci_remove_adv_instance().
If that's the case, we will mistakenly proceed to remove all adv
instances instead of just one single instance.

This patch fixes the issue by checking the content of the HCI command
instead of checking whether the adv_info is found.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/hci_event.c