* [PATCH] Bluetooth: rfcomm: fix modem control handling
@ 2025-10-23 12:01 Johan Hovold
2025-10-23 12:50 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2025-10-23 12:01 UTC (permalink / raw)
To: Luiz Augusto von Dentz, Marcel Holtmann, Johan Hedberg
Cc: linux-bluetooth, linux-kernel, Johan Hovold, stable
The RFCOMM driver confuses the local and remote modem control signals,
which specifically means that the reported DTR and RTS state will
instead reflect the remote end (i.e. DSR and CTS).
This issue dates back to the original driver (and a follow-on update)
merged in 2002, which resulted in a non-standard implementation of
TIOCMSET that allowed controlling also the TS07.10 IC and DV signals by
mapping them to the RI and DCD input flags, while TIOCMGET failed to
return the actual state of DTR and RTS.
Note that the bogus control of input signals in tiocmset() is just
dead code as those flags will have been masked out by the tty layer
since 2003.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
net/bluetooth/rfcomm/tty.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 376ce6de84be..f20f043cc9b5 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -643,8 +643,8 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
tty_port_tty_hangup(&dev->port, true);
dev->modem_status =
- ((v24_sig & RFCOMM_V24_RTC) ? (TIOCM_DSR | TIOCM_DTR) : 0) |
- ((v24_sig & RFCOMM_V24_RTR) ? (TIOCM_RTS | TIOCM_CTS) : 0) |
+ ((v24_sig & RFCOMM_V24_RTC) ? TIOCM_DSR : 0) |
+ ((v24_sig & RFCOMM_V24_RTR) ? TIOCM_CTS : 0) |
((v24_sig & RFCOMM_V24_IC) ? TIOCM_RI : 0) |
((v24_sig & RFCOMM_V24_DV) ? TIOCM_CD : 0);
}
@@ -1055,10 +1055,13 @@ static void rfcomm_tty_hangup(struct tty_struct *tty)
static int rfcomm_tty_tiocmget(struct tty_struct *tty)
{
struct rfcomm_dev *dev = tty->driver_data;
+ u8 v24_sig;
BT_DBG("tty %p dev %p", tty, dev);
- return dev->modem_status;
+ rfcomm_dlc_get_modem_status(dlc, &v24_sig);
+
+ return (v24_sig & (TIOCM_DTR | TIOCM_RTS)) | dev->modem_status;
}
static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
@@ -1071,23 +1074,15 @@ static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigne
rfcomm_dlc_get_modem_status(dlc, &v24_sig);
- if (set & TIOCM_DSR || set & TIOCM_DTR)
+ if (set & TIOCM_DTR)
v24_sig |= RFCOMM_V24_RTC;
- if (set & TIOCM_RTS || set & TIOCM_CTS)
+ if (set & TIOCM_RTS)
v24_sig |= RFCOMM_V24_RTR;
- if (set & TIOCM_RI)
- v24_sig |= RFCOMM_V24_IC;
- if (set & TIOCM_CD)
- v24_sig |= RFCOMM_V24_DV;
- if (clear & TIOCM_DSR || clear & TIOCM_DTR)
+ if (clear & TIOCM_DTR)
v24_sig &= ~RFCOMM_V24_RTC;
- if (clear & TIOCM_RTS || clear & TIOCM_CTS)
+ if (clear & TIOCM_RTS)
v24_sig &= ~RFCOMM_V24_RTR;
- if (clear & TIOCM_RI)
- v24_sig &= ~RFCOMM_V24_IC;
- if (clear & TIOCM_CD)
- v24_sig &= ~RFCOMM_V24_DV;
rfcomm_dlc_set_modem_status(dlc, v24_sig);
--
2.49.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: Bluetooth: rfcomm: fix modem control handling
2025-10-23 12:01 [PATCH] Bluetooth: rfcomm: fix modem control handling Johan Hovold
@ 2025-10-23 12:50 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2025-10-23 12:50 UTC (permalink / raw)
To: linux-bluetooth, johan
[-- Attachment #1: Type: text/plain, Size: 7301 bytes --]
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=1014979
---Test result---
Test Summary:
CheckPatch PENDING 0.38 seconds
GitLint PENDING 0.28 seconds
SubjectPrefix PASS 0.08 seconds
BuildKernel FAIL 17.72 seconds
CheckAllWarning FAIL 19.38 seconds
CheckSparse FAIL 21.16 seconds
BuildKernel32 FAIL 16.88 seconds
TestRunnerSetup PASS 488.31 seconds
TestRunner_l2cap-tester PASS 23.91 seconds
TestRunner_iso-tester FAIL 60.16 seconds
TestRunner_bnep-tester PASS 6.34 seconds
TestRunner_mgmt-tester FAIL 125.50 seconds
TestRunner_rfcomm-tester PASS 9.36 seconds
TestRunner_sco-tester PASS 14.47 seconds
TestRunner_ioctl-tester PASS 10.09 seconds
TestRunner_mesh-tester FAIL 11.36 seconds
TestRunner_smp-tester PASS 8.45 seconds
TestRunner_userchan-tester PASS 6.38 seconds
IncrementalBuild PENDING 1.07 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: BuildKernel - FAIL
Desc: Build Kernel for Bluetooth
Output:
net/bluetooth/rfcomm/tty.c: In function ‘rfcomm_tty_tiocmget’:
net/bluetooth/rfcomm/tty.c:1062:30: error: ‘dlc’ undeclared (first use in this function)
1062 | rfcomm_dlc_get_modem_status(dlc, &v24_sig);
| ^~~
net/bluetooth/rfcomm/tty.c:1062:30: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [scripts/Makefile.build:287: net/bluetooth/rfcomm/tty.o] Error 1
make[4]: *** [scripts/Makefile.build:556: net/bluetooth/rfcomm] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:556: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:556: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2011: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: CheckAllWarning - FAIL
Desc: Run linux kernel with all warning enabled
Output:
net/bluetooth/rfcomm/tty.c: In function ‘rfcomm_tty_tiocmget’:
net/bluetooth/rfcomm/tty.c:1062:30: error: ‘dlc’ undeclared (first use in this function)
1062 | rfcomm_dlc_get_modem_status(dlc, &v24_sig);
| ^~~
net/bluetooth/rfcomm/tty.c:1062:30: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [scripts/Makefile.build:287: net/bluetooth/rfcomm/tty.o] Error 1
make[4]: *** [scripts/Makefile.build:556: net/bluetooth/rfcomm] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:556: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:556: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2011: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: CheckSparse - FAIL
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/rfcomm/tty.c: In function ‘rfcomm_tty_tiocmget’:
net/bluetooth/rfcomm/tty.c:1062:30: error: ‘dlc’ undeclared (first use in this function)
1062 | rfcomm_dlc_get_modem_status(dlc, &v24_sig);
| ^~~
net/bluetooth/rfcomm/tty.c:1062:30: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [scripts/Makefile.build:287: net/bluetooth/rfcomm/tty.o] Error 1
make[4]: *** [scripts/Makefile.build:556: net/bluetooth/rfcomm] Error 2
make[4]: *** Waiting for unfinished jobs....
net/bluetooth/af_bluetooth.c:248:25: warning: context imbalance in 'bt_accept_enqueue' - different lock contexts for basic block
make[3]: *** [scripts/Makefile.build:556: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:556: net] Error 2
make[2]: *** Waiting for unfinished jobs....
drivers/bluetooth/hci_ag6xx.c:257:24: warning: restricted __le32 degrades to integer
drivers/bluetooth/hci_mrvl.c:170:23: warning: restricted __le16 degrades to integer
drivers/bluetooth/hci_mrvl.c:203:23: warning: restricted __le16 degrades to integer
drivers/bluetooth/hci_nokia.c:279:23: warning: incorrect type in assignment (different base types)
drivers/bluetooth/hci_nokia.c:279:23: expected unsigned short [usertype] baud
drivers/bluetooth/hci_nokia.c:279:23: got restricted __le16 [usertype]
drivers/bluetooth/hci_nokia.c:282:26: warning: incorrect type in assignment (different base types)
drivers/bluetooth/hci_nokia.c:282:26: expected unsigned short [usertype] sys_clk
drivers/bluetooth/hci_nokia.c:282:26: got restricted __le16 [usertype]
make[1]: *** [/github/workspace/src/src/Makefile:2011: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: BuildKernel32 - FAIL
Desc: Build 32bit Kernel for Bluetooth
Output:
net/bluetooth/rfcomm/tty.c: In function ‘rfcomm_tty_tiocmget’:
net/bluetooth/rfcomm/tty.c:1062:30: error: ‘dlc’ undeclared (first use in this function)
1062 | rfcomm_dlc_get_modem_status(dlc, &v24_sig);
| ^~~
net/bluetooth/rfcomm/tty.c:1062:30: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [scripts/Makefile.build:287: net/bluetooth/rfcomm/tty.o] Error 1
make[4]: *** [scripts/Makefile.build:556: net/bluetooth/rfcomm] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:556: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:556: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2011: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
No test result found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 483 (98.6%), Failed: 3, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.105 seconds
LL Privacy - Add Device 2 (2 Devices to AL) Failed 0.182 seconds
LL Privacy - Set Flags 2 (Enable RL) Failed 0.154 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 1.878 seconds
Mesh - Send cancel - 2 Timed out 1.996 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-23 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 12:01 [PATCH] Bluetooth: rfcomm: fix modem control handling Johan Hovold
2025-10-23 12:50 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).