Skip to content

Commit fe0ebea

Browse files
TomRita999gregkh
authored andcommitted
staging: greybus: uart: 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 meaningless. Signed-off-by: Qiu-ji Chen <[email protected]> Fixes: 0aad5ad ("greybus/uart: switch to ->[sg]et_serial()") Reviewed-by: Johan Hovold <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Alex Elder <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c483887 commit fe0ebea

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/staging/greybus/uart.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,13 @@ static int get_serial_info(struct tty_struct *tty,
596596
struct gb_tty *gb_tty = tty->driver_data;
597597

598598
ss->line = gb_tty->minor;
599+
mutex_lock(&gb_tty->port.mutex);
599600
ss->close_delay = jiffies_to_msecs(gb_tty->port.close_delay) / 10;
600601
ss->closing_wait =
601602
gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
602603
ASYNC_CLOSING_WAIT_NONE :
603604
jiffies_to_msecs(gb_tty->port.closing_wait) / 10;
605+
mutex_unlock(&gb_tty->port.mutex);
604606

605607
return 0;
606608
}

0 commit comments

Comments
 (0)