mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
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 <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20221116162152.193147-35-john.ogness@linutronix.de
This commit is contained in:
@@ -33,7 +33,16 @@ static int show_console_dev(struct seq_file *m, void *v)
|
|||||||
if (con->device) {
|
if (con->device) {
|
||||||
const struct tty_driver *driver;
|
const struct tty_driver *driver;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Take console_lock to serialize device() callback with
|
||||||
|
* other console operations. For example, fg_console is
|
||||||
|
* modified under console_lock when switching vt.
|
||||||
|
*/
|
||||||
|
console_lock();
|
||||||
driver = con->device(con, &index);
|
driver = con->device(con, &index);
|
||||||
|
console_unlock();
|
||||||
|
|
||||||
if (driver) {
|
if (driver) {
|
||||||
dev = MKDEV(driver->major, driver->minor_start);
|
dev = MKDEV(driver->major, driver->minor_start);
|
||||||
dev += index;
|
dev += index;
|
||||||
@@ -64,15 +73,11 @@ static void *c_start(struct seq_file *m, loff_t *pos)
|
|||||||
loff_t off = 0;
|
loff_t off = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take console_lock to serialize device() callback with
|
* Hold the console_list_lock to guarantee safe traversal of the
|
||||||
* other console operations. For example, fg_console is
|
|
||||||
* modified under console_lock when switching vt.
|
|
||||||
*
|
|
||||||
* Hold the console_lock to guarantee safe traversal of the
|
|
||||||
* console list. SRCU cannot be used because there is no
|
* console list. SRCU cannot be used because there is no
|
||||||
* place to store the SRCU cookie.
|
* place to store the SRCU cookie.
|
||||||
*/
|
*/
|
||||||
console_lock();
|
console_list_lock();
|
||||||
for_each_console(con)
|
for_each_console(con)
|
||||||
if (off++ == *pos)
|
if (off++ == *pos)
|
||||||
break;
|
break;
|
||||||
@@ -90,7 +95,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos)
|
|||||||
|
|
||||||
static void c_stop(struct seq_file *m, void *v)
|
static void c_stop(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
console_unlock();
|
console_list_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct seq_operations consoles_op = {
|
static const struct seq_operations consoles_op = {
|
||||||
|
Reference in New Issue
Block a user