From: Luiz Augusto von Dentz <[email protected]>
Even though l2cap_chan_del calls __clear_chan_timer that uses
cancel_delayed_work which doesn't prevent the work to run as it could be
already pending.
So instead this check if chan->conn has been set to NULL, which indicates
that l2cap_conn_del might have run, and proceed to release its reference
since the channel has already been cleanup.
Reported-by: [email protected]
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
net/bluetooth/l2cap_core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9ebb85df4db4..4408e07a00d1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -414,11 +414,21 @@ static void l2cap_chan_timeout(struct work_struct *work)
{
struct l2cap_chan *chan = container_of(work, struct l2cap_chan,
chan_timer.work);
- struct l2cap_conn *conn = chan->conn;
+ struct l2cap_conn *conn;
int reason;
BT_DBG("chan %p state %s", chan, state_to_string(chan->state));
+ conn = chan->conn;
+ if (!conn) {
+ /* Channel is no longer attached to a connection so
+ * l2cap_conn_del might have run, just release reference
+ * acquired via __set_chan_timer.
+ */
+ l2cap_chan_put(chan);
+ return;
+ }
+
mutex_lock(&conn->chan_lock);
/* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling
* this work. No need to call l2cap_chan_hold(chan) here again.
--
2.31.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=492905
---Test result---
Test Summary:
CheckPatch PASS 0.47 seconds
GitLint PASS 0.11 seconds
BuildKernel PASS 507.46 seconds
TestRunner: Setup PASS 327.25 seconds
TestRunner: l2cap-tester PASS 2.50 seconds
TestRunner: bnep-tester PASS 1.86 seconds
TestRunner: mgmt-tester PASS 27.38 seconds
TestRunner: rfcomm-tester PASS 2.01 seconds
TestRunner: sco-tester PASS 2.00 seconds
TestRunner: smp-tester PASS 2.02 seconds
TestRunner: userchan-tester PASS 1.95 seconds
Details
##############################
Test: CheckPatch - PASS - 0.47 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
##############################
Test: GitLint - PASS - 0.11 seconds
Run gitlint with rule in .gitlint
##############################
Test: BuildKernel - PASS - 507.46 seconds
Build Kernel with minimal configuration supports Bluetooth
##############################
Test: TestRunner: Setup - PASS - 327.25 seconds
Setup environment for running Test Runner
##############################
Test: TestRunner: l2cap-tester - PASS - 2.50 seconds
Run test-runner with l2cap-tester
Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner: bnep-tester - PASS - 1.86 seconds
Run test-runner with bnep-tester
Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner: mgmt-tester - PASS - 27.38 seconds
Run test-runner with mgmt-tester
Total: 446, Passed: 433 (97.1%), Failed: 0, Not Run: 13
##############################
Test: TestRunner: rfcomm-tester - PASS - 2.01 seconds
Run test-runner with rfcomm-tester
Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner: sco-tester - PASS - 2.00 seconds
Run test-runner with sco-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner: smp-tester - PASS - 2.02 seconds
Run test-runner with smp-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner: userchan-tester - PASS - 1.95 seconds
Run test-runner with userchan-tester
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
---
Regards,
Linux Bluetooth