Skip to content

Commit 28de287

Browse files
jognesspmladek
authored andcommitted
proc: consoles: use console_list_lock for list iteration
The console_lock is used in part to guarantee safe list iteration. 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: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7c2af0f commit 28de287

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

fs/proc/consoles.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ static int show_console_dev(struct seq_file *m, void *v)
3333
if (con->device) {
3434
const struct tty_driver *driver;
3535
int index;
36+
37+
/*
38+
* Take console_lock to serialize device() callback with
39+
* other console operations. For example, fg_console is
40+
* modified under console_lock when switching vt.
41+
*/
42+
console_lock();
3643
driver = con->device(con, &index);
44+
console_unlock();
45+
3746
if (driver) {
3847
dev = MKDEV(driver->major, driver->minor_start);
3948
dev += index;
@@ -64,15 +73,11 @@ static void *c_start(struct seq_file *m, loff_t *pos)
6473
loff_t off = 0;
6574

6675
/*
67-
* Take console_lock to serialize device() callback with
68-
* other console operations. For example, fg_console is
69-
* modified under console_lock when switching vt.
70-
*
71-
* Hold the console_lock to guarantee safe traversal of the
76+
* Hold the console_list_lock to guarantee safe traversal of the
7277
* console list. SRCU cannot be used because there is no
7378
* place to store the SRCU cookie.
7479
*/
75-
console_lock();
80+
console_list_lock();
7681
for_each_console(con)
7782
if (off++ == *pos)
7883
break;
@@ -90,7 +95,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos)
9095

9196
static void c_stop(struct seq_file *m, void *v)
9297
{
93-
console_unlock();
98+
console_list_unlock();
9499
}
95100

96101
static const struct seq_operations consoles_op = {

0 commit comments

Comments
 (0)