Skip to content

Commit 7c2af0f

Browse files
jognesspmladek
authored andcommitted
tty: tty_io: use console_list_lock for list synchronization
show_cons_active() uses the console_lock to gather information on registered consoles. It requires that no consoles are unregistered until it is finished. The console_list_lock should be used because list synchronization responsibility will be removed from the console_lock in a later change. Note, the console_lock is still needed to serialize the device() callback with other console operations. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6f88367 commit 7c2af0f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/tty/tty_io.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,16 +3527,13 @@ static ssize_t show_cons_active(struct device *dev,
35273527
ssize_t count = 0;
35283528

35293529
/*
3530-
* Hold the console_lock to guarantee that no consoles are
3530+
* Hold the console_list_lock to guarantee that no consoles are
35313531
* unregistered until all console processing is complete.
35323532
* This also allows safe traversal of the console list and
35333533
* race-free reading of @flags.
3534-
*
3535-
* Take console_lock to serialize device() callback with
3536-
* other console operations. For example, fg_console is
3537-
* modified under console_lock when switching vt.
35383534
*/
3539-
console_lock();
3535+
console_list_lock();
3536+
35403537
for_each_console(c) {
35413538
if (!c->device)
35423539
continue;
@@ -3548,6 +3545,13 @@ static ssize_t show_cons_active(struct device *dev,
35483545
if (i >= ARRAY_SIZE(cs))
35493546
break;
35503547
}
3548+
3549+
/*
3550+
* Take console_lock to serialize device() callback with
3551+
* other console operations. For example, fg_console is
3552+
* modified under console_lock when switching vt.
3553+
*/
3554+
console_lock();
35513555
while (i--) {
35523556
int index = cs[i]->index;
35533557
struct tty_driver *drv = cs[i]->device(cs[i], &index);
@@ -3563,6 +3567,8 @@ static ssize_t show_cons_active(struct device *dev,
35633567
}
35643568
console_unlock();
35653569

3570+
console_list_unlock();
3571+
35663572
return count;
35673573
}
35683574
static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);

0 commit comments

Comments
 (0)