Skip to content

Commit 62d65bd

Browse files
HiassofTgregkh
authored andcommitted
USB: cdc-acm: restore capability check order
commit b401f8c ("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: b401f8c ("USB: cdc-acm: fix rounding error in TIOCSSERIAL") Cc: Anthony Mallet <[email protected]> Cc: stable <[email protected]> Cc: Oliver Neukum <[email protected]> Signed-off-by: Matthias Reichl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 70d8b9e commit 62d65bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -923,16 +923,16 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
923923

924924
mutex_lock(&acm->port.mutex);
925925

926-
if ((ss->close_delay != old_close_delay) ||
927-
(ss->closing_wait != old_closing_wait)) {
928-
if (!capable(CAP_SYS_ADMIN))
926+
if (!capable(CAP_SYS_ADMIN)) {
927+
if ((ss->close_delay != old_close_delay) ||
928+
(ss->closing_wait != old_closing_wait))
929929
retval = -EPERM;
930-
else {
931-
acm->port.close_delay = close_delay;
932-
acm->port.closing_wait = closing_wait;
933-
}
934-
} else
935-
retval = -EOPNOTSUPP;
930+
else
931+
retval = -EOPNOTSUPP;
932+
} else {
933+
acm->port.close_delay = close_delay;
934+
acm->port.closing_wait = closing_wait;
935+
}
936936

937937
mutex_unlock(&acm->port.mutex);
938938
return retval;

0 commit comments

Comments
 (0)