linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: cdc-acm: restore capability check order
@ 2020-03-27 15:03 Matthias Reichl
  2020-03-27 15:33 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Reichl @ 2020-03-27 15:03 UTC (permalink / raw)
  To: Anthony Mallet, Greg Kroah-Hartman, Oliver Neukum
  Cc: linux-usb, Matthias Reichl

commit b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
introduced a regression by changing the order of capability and close
settings change checks. When running with CAP_SYS_ADMIN setting the
close settings to the values already set resulted in -EOPNOTSUPP.

Fix this by changing the check order back to how it was before.

Fixes: b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
Signed-off-by: Matthias Reichl <hias@horus.com>
---
 drivers/usb/class/cdc-acm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 47f09a6ce7bda..84d6f7df09a4e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -923,16 +923,16 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 
 	mutex_lock(&acm->port.mutex);
 
-	if ((ss->close_delay != old_close_delay) ||
-            (ss->closing_wait != old_closing_wait)) {
-		if (!capable(CAP_SYS_ADMIN))
+	if (!capable(CAP_SYS_ADMIN)) {
+		if ((ss->close_delay != old_close_delay) ||
+		    (ss->closing_wait != old_closing_wait))
 			retval = -EPERM;
-		else {
-			acm->port.close_delay  = close_delay;
-			acm->port.closing_wait = closing_wait;
-		}
-	} else
-		retval = -EOPNOTSUPP;
+		else
+			retval = -EOPNOTSUPP;
+	} else {
+		acm->port.close_delay  = close_delay;
+		acm->port.closing_wait = closing_wait;
+	}
 
 	mutex_unlock(&acm->port.mutex);
 	return retval;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB: cdc-acm: restore capability check order
  2020-03-27 15:03 [PATCH] USB: cdc-acm: restore capability check order Matthias Reichl
@ 2020-03-27 15:33 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-03-27 15:33 UTC (permalink / raw)
  To: Matthias Reichl; +Cc: Anthony Mallet, Oliver Neukum, linux-usb

On Fri, Mar 27, 2020 at 04:03:50PM +0100, Matthias Reichl wrote:
> commit b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
> introduced a regression by changing the order of capability and close
> settings change checks. When running with CAP_SYS_ADMIN setting the
> close settings to the values already set resulted in -EOPNOTSUPP.
> 
> Fix this by changing the check order back to how it was before.
> 
> Fixes: b401f8c4f492c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
> Cc: Anthony Mallet <anthony.mallet@laas.fr>
> Cc: stable <stable@vger.kernel.org>
> Cc: Oliver Neukum <oneukum@suse.com>
> Signed-off-by: Matthias Reichl <hias@horus.com>
> ---
>  drivers/usb/class/cdc-acm.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

Thanks for this, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-27 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 15:03 [PATCH] USB: cdc-acm: restore capability check order Matthias Reichl
2020-03-27 15:33 ` Greg Kroah-Hartman

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).