diff mbox series

Bluetooth: call hci_le_conn_failed with hdev lock in hci_le_conn_failed

Message ID 20220316152027.9988-1-dossche.niels@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series Bluetooth: call hci_le_conn_failed with hdev lock in hci_le_conn_failed | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 3 maintainers not CCed: davem@davemloft.net linux-bluetooth@vger.kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Niels Dossche March 16, 2022, 3:20 p.m. UTC
hci_le_conn_failed function's documentation says that the caller must
hold hdev->lock. The only callsite that does not hold that lock is
hci_le_conn_failed. The other 3 callsites hold the hdev->lock very
locally. The solution is to hold the lock during the call to
hci_le_conn_failed.

Fixes: 3c857757ef6e ("Bluetooth: Add directed advertising support through connect()")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
 net/bluetooth/hci_conn.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Marcel Holtmann March 16, 2022, 3:32 p.m. UTC | #1
Hi Niels,

> hci_le_conn_failed function's documentation says that the caller must
> hold hdev->lock. The only callsite that does not hold that lock is
> hci_le_conn_failed. The other 3 callsites hold the hdev->lock very
> locally. The solution is to hold the lock during the call to
> hci_le_conn_failed.
> 
> Fixes: 3c857757ef6e ("Bluetooth: Add directed advertising support through connect()")
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
> ---
> net/bluetooth/hci_conn.c | 2 ++
> 1 file changed, 2 insertions(+)

please send net/bluetooth/ to linux-bluetooth mailing list.

Regards

Marcel
Niels Dossche March 16, 2022, 3:33 p.m. UTC | #2
On 16/03/2022 16:32, Marcel Holtmann wrote:
> Hi Niels,
> 
>> hci_le_conn_failed function's documentation says that the caller must
>> hold hdev->lock. The only callsite that does not hold that lock is
>> hci_le_conn_failed. The other 3 callsites hold the hdev->lock very
>> locally. The solution is to hold the lock during the call to
>> hci_le_conn_failed.
>>
>> Fixes: 3c857757ef6e ("Bluetooth: Add directed advertising support through connect()")
>> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
>> ---
>> net/bluetooth/hci_conn.c | 2 ++
>> 1 file changed, 2 insertions(+)
> 
> please send net/bluetooth/ to linux-bluetooth mailing list.
> 
> Regards
> 
> Marcel
> 

Hi Marcel
My bad, I'll resend it to there, I have copied the wrong mail address.
Regards
Niels
diff mbox series

Patch

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 04ebe901e86f..3bb2b3b6a1c9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -669,7 +669,9 @@  static void le_conn_timeout(struct work_struct *work)
 	if (conn->role == HCI_ROLE_SLAVE) {
 		/* Disable LE Advertising */
 		le_disable_advertising(hdev);
+		hci_dev_lock(hdev);
 		hci_le_conn_failed(conn, HCI_ERROR_ADVERTISING_TIMEOUT);
+		hci_dev_unlock(hdev);
 		return;
 	}