Skip to content

Commit 8b52494

Browse files
TomRita999jhovold
authored andcommitted
USB: serial: ftdi_sio: Fix atomicity violation in get_serial_info()
Our static checker found a bug where set_serial_info() uses a mutex, but get_serial_info() does not. Fortunately, the impact of this is relatively minor. It doesn't cause a crash or any other serious issues. However, if a race condition occurs between set_serial_info() and get_serial_info(), there is a chance that the data returned by get_serial_info() will be inconsistent. Fixes: 3ae36be ("fdti_sio: switch to ->[sg]et_serial()") Signed-off-by: Qiu-ji Chen <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent 4082772 commit 8b52494

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/serial/ftdi_sio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,9 +1443,11 @@ static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
14431443
struct usb_serial_port *port = tty->driver_data;
14441444
struct ftdi_private *priv = usb_get_serial_port_data(port);
14451445

1446+
mutex_lock(&priv->cfg_lock);
14461447
ss->flags = priv->flags;
14471448
ss->baud_base = priv->baud_base;
14481449
ss->custom_divisor = priv->custom_divisor;
1450+
mutex_unlock(&priv->cfg_lock);
14491451
}
14501452

14511453
static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)

0 commit comments

Comments
 (0)