diff mbox series

[2/4] Bluetooth: Only allow setting AOSP capable at setup stage

Message ID 20211012213158.2635219-2-luiz.dentz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [1/4] Bluetooth: Only allow setting msft_opcode at setup stage | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS

Commit Message

Luiz Augusto von Dentz Oct. 12, 2021, 9:31 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The aosp_capable flag shall only be changed while at the setup stage
otherwise it can possible take no effect.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 include/net/bluetooth/hci_core.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index eb5d4ea88c3a..ac81745d2ac4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1283,11 +1283,16 @@  static inline int hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
 	return 0;
 }
 
-static inline void hci_set_aosp_capable(struct hci_dev *hdev)
+static inline int hci_set_aosp_capable(struct hci_dev *hdev)
 {
+	if (!hci_dev_test_flag(hdev, HCI_SETUP))
+		return -EPERM;
+
 #if IS_ENABLED(CONFIG_BT_AOSPEXT)
 	hdev->aosp_capable = true;
 #endif
+
+	return 0;
 }
 
 int hci_dev_open(__u16 dev);