| From e3814cfb964bc0c9e4df5a0290e13b67329a772e Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 8 Apr 2021 15:16:02 +0200 |
| Subject: USB: cdc-acm: fix TIOCGSERIAL implementation |
| |
| From: Johan Hovold <johan@kernel.org> |
| |
| [ Upstream commit 496960274153bdeb9d1f904ff1ea875cef8232c1 ] |
| |
| TIOCSSERIAL is a horrid, underspecified, legacy interface which for most |
| serial devices is only useful for setting the close_delay and |
| closing_wait parameters. |
| |
| The xmit_fifo_size parameter could be used to set the hardware transmit |
| fifo size of a legacy UART when it could not be detected, but the |
| interface is limited to eight bits and should be left unset when it is |
| not used. |
| |
| Similarly, baud_base could be used to set the UART base clock when it |
| could not be detected, but might as well be left unset when it is not |
| known (which is the case for CDC). |
| |
| Fix the cdc-acm TIOCGSERIAL implementation by dropping its custom |
| interpretation of the unused xmit_fifo_size and baud_base fields, which |
| overflowed the former with the URB buffer size and set the latter to the |
| current line speed. Also return the port line number, which is the only |
| other value used besides the close parameters. |
| |
| Note that the current line speed can still be retrieved through the |
| standard termios interfaces. |
| |
| Fixes: 18c75720e667 ("USB: allow users to run setserial with cdc-acm") |
| Acked-by: Oliver Neukum <oneukum@suse.com> |
| Signed-off-by: Johan Hovold <johan@kernel.org> |
| Link: https://lore.kernel.org/r/20210408131602.27956-4-johan@kernel.org |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/usb/class/cdc-acm.c | 3 +-- |
| 1 file changed, 1 insertion(+), 2 deletions(-) |
| |
| diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
| index 63824552e5d0..6fbabf56dbb7 100644 |
| --- a/drivers/usb/class/cdc-acm.c |
| +++ b/drivers/usb/class/cdc-acm.c |
| @@ -929,8 +929,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) |
| { |
| struct acm *acm = tty->driver_data; |
| |
| - ss->xmit_fifo_size = acm->writesize; |
| - ss->baud_base = le32_to_cpu(acm->line.dwDTERate); |
| + ss->line = acm->minor; |
| ss->close_delay = jiffies_to_msecs(acm->port.close_delay) / 10; |
| ss->closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? |
| ASYNC_CLOSING_WAIT_NONE : |
| -- |
| 2.30.2 |
| |