Blob Blame History Raw
From a3cb01e2fe3793b8ffcb9cc7f7c7f2ca55793e62 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Wed, 7 Apr 2021 12:39:17 +0200
Subject: [PATCH] USB: serial: usb_wwan: fix unprivileged TIOCCSERIAL
Git-commit: a3cb01e2fe3793b8ffcb9cc7f7c7f2ca55793e62
Patch-mainline: v5.13-rc1
References: git-fixes

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

A non-privileged user has only ever been able to set the since long
deprecated ASYNC_SPD flags and trying to change any other *supported*
feature should result in -EPERM being returned. Setting the current
values for any supported features should return success.

Fix the usb_wwan implementation which instead indicated that the
TIOCSSERIAL ioctl was not even implemented when a non-privileged user
set the current values.

Fixes: 02303f73373a ("usb-wwan: implement TIOCGSERIAL and TIOCSSERIAL to avoid blocking close(2)")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/usb/serial/usb_wwan.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 4e9c994a972a..e71c828682f5 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -166,8 +166,6 @@ int usb_wwan_set_serial_info(struct tty_struct *tty,
 		if ((close_delay != port->port.close_delay) ||
 		    (closing_wait != port->port.closing_wait))
 			retval = -EPERM;
-		else
-			retval = -EOPNOTSUPP;
 	} else {
 		port->port.close_delay  = close_delay;
 		port->port.closing_wait = closing_wait;
-- 
2.26.2