diff mbox series

[v2,1/4] Bluetooth: Only allow setting msft_opcode at setup stage

Message ID 20211013003055.2664728-1-luiz.dentz@gmail.com (mailing list archive)
State Superseded
Delegated to: Luiz Von Dentz
Headers show
Series [v2,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
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 468, Passed: 468 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Luiz Augusto von Dentz Oct. 13, 2021, 12:30 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The msft_opcode shall only be changed while at the setup stage otherwise
it can possible cause problems where different opcodes are used while
running.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
v2: Fix typos: s/extention/extension/g

 include/net/bluetooth/hci_core.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Oct. 13, 2021, 2:11 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=562233

---Test result---

Test Summary:
CheckPatch                    PASS      6.63 seconds
GitLint                       PASS      3.63 seconds
BuildKernel                   PASS      613.81 seconds
TestRunner: Setup             PASS      449.45 seconds
TestRunner: l2cap-tester      PASS      10.26 seconds
TestRunner: bnep-tester       PASS      5.53 seconds
TestRunner: mgmt-tester       PASS      92.99 seconds
TestRunner: rfcomm-tester     PASS      6.82 seconds
TestRunner: sco-tester        PASS      7.06 seconds
TestRunner: smp-tester        PASS      6.84 seconds
TestRunner: userchan-tester   PASS      5.79 seconds



---
Regards,
Linux Bluetooth
Marcel Holtmann Oct. 13, 2021, 6:35 a.m. UTC | #2
Hi Luiz,

> The msft_opcode shall only be changed while at the setup stage otherwise
> it can possible cause problems where different opcodes are used while
> running.
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> v2: Fix typos: s/extention/extension/g
> 
> include/net/bluetooth/hci_core.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index dd8840e70e25..eb5d4ea88c3a 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1272,11 +1272,15 @@ int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb);
> __printf(2, 3) void hci_set_hw_info(struct hci_dev *hdev, const char *fmt, ...);
> __printf(2, 3) void hci_set_fw_info(struct hci_dev *hdev, const char *fmt, ...);
> 
> -static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
> +static inline int hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
> {
> +	if (!hci_dev_test_flag(hdev, HCI_SETUP))
> +		return -EPERM;
> +
> #if IS_ENABLED(CONFIG_BT_MSFTEXT)
> 	hdev->msft_opcode = opcode;
> #endif
> +	return 0;
> }

this is also not going to work since some driver might set it in their probe() routine before calling hci_register_dev.

Regards

Marcel
Luiz Augusto von Dentz Oct. 13, 2021, 9:10 p.m. UTC | #3
Hi Marcel,

On Tue, Oct 12, 2021 at 11:35 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Luiz,
>
> > The msft_opcode shall only be changed while at the setup stage otherwise
> > it can possible cause problems where different opcodes are used while
> > running.
> >
> > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > ---
> > v2: Fix typos: s/extention/extension/g
> >
> > include/net/bluetooth/hci_core.h | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> > index dd8840e70e25..eb5d4ea88c3a 100644
> > --- a/include/net/bluetooth/hci_core.h
> > +++ b/include/net/bluetooth/hci_core.h
> > @@ -1272,11 +1272,15 @@ int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb);
> > __printf(2, 3) void hci_set_hw_info(struct hci_dev *hdev, const char *fmt, ...);
> > __printf(2, 3) void hci_set_fw_info(struct hci_dev *hdev, const char *fmt, ...);
> >
> > -static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
> > +static inline int hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
> > {
> > +     if (!hci_dev_test_flag(hdev, HCI_SETUP))
> > +             return -EPERM;
> > +
> > #if IS_ENABLED(CONFIG_BT_MSFTEXT)
> >       hdev->msft_opcode = opcode;
> > #endif
> > +     return 0;
> > }
>
> this is also not going to work since some driver might set it in their probe() routine before calling hci_register_dev.

Shall we allow that though? Perhaps we should be checking for HCI_RUNNING then?
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index dd8840e70e25..eb5d4ea88c3a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1272,11 +1272,15 @@  int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb);
 __printf(2, 3) void hci_set_hw_info(struct hci_dev *hdev, const char *fmt, ...);
 __printf(2, 3) void hci_set_fw_info(struct hci_dev *hdev, const char *fmt, ...);
 
-static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
+static inline int hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode)
 {
+	if (!hci_dev_test_flag(hdev, HCI_SETUP))
+		return -EPERM;
+
 #if IS_ENABLED(CONFIG_BT_MSFTEXT)
 	hdev->msft_opcode = opcode;
 #endif
+	return 0;
 }
 
 static inline void hci_set_aosp_capable(struct hci_dev *hdev)