Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4826a0be authored by Matthias Reichl's avatar Matthias Reichl Committed by Greg Kroah-Hartman
Browse files

USB: cdc-acm: restore capability check order



commit 62d65bdd9d05158aa2547f8ef72375535f3bc6e3 upstream.

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: default avatarMatthias Reichl <hias@horus.com>
Link: https://lore.kernel.org/r/20200327150350.3657-1-hias@horus.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ce6edbf0
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -863,16 +863,16 @@ static int set_serial_info(struct acm *acm,


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


	if (!capable(CAP_SYS_ADMIN)) {
		if ((new_serial.close_delay != old_close_delay) ||
		if ((new_serial.close_delay != old_close_delay) ||
            (new_serial.closing_wait != old_closing_wait)) {
	            (new_serial.closing_wait != old_closing_wait))
		if (!capable(CAP_SYS_ADMIN))
			retval = -EPERM;
			retval = -EPERM;
		else {
		else
			retval = -EOPNOTSUPP;
	} else {
		acm->port.close_delay  = close_delay;
		acm->port.close_delay  = close_delay;
		acm->port.closing_wait = closing_wait;
		acm->port.closing_wait = closing_wait;
	}
	}
	} else
		retval = -EOPNOTSUPP;


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