summaryrefslogtreecommitdiffstats
path: root/drivers/video/fbdev/xen-fbfront.c
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2022-11-16 17:21:44 +0100
committerPetr Mladek <pmladek@suse.com>2022-12-02 11:25:02 +0100
commit6f8836756f3cbb02bfd1f0e033516585250318a9 (patch)
treeda70918f2ac3f0ad26c930085eabeab7b285a915 /drivers/video/fbdev/xen-fbfront.c
parentnetconsole: avoid CON_ENABLED misuse to track registration (diff)
downloadlinux-6f8836756f3cbb02bfd1f0e033516585250318a9.tar.xz
linux-6f8836756f3cbb02bfd1f0e033516585250318a9.zip
printk, xen: fbfront: create/use safe function for forcing preferred
With commit 9e124fe16ff2("xen: Enable console tty by default in domU if it's not a dummy") a hack was implemented to make sure that the tty console remains the console behind the /dev/console device. The main problem with the hack is that, after getting the console pointer to the tty console, it is assumed the pointer is still valid after releasing the console_sem. This assumption is incorrect and unsafe. Make the hack safe by introducing a new function console_force_preferred_locked() and perform the full operation under the console_list_lock. 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-33-john.ogness@linutronix.de
Diffstat (limited to 'drivers/video/fbdev/xen-fbfront.c')
-rw-r--r--drivers/video/fbdev/xen-fbfront.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c
index 4d2694d904aa..8752d389e382 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -504,18 +504,14 @@ static void xenfb_make_preferred_console(void)
if (console_set_on_cmdline)
return;
- console_lock();
+ console_list_lock();
for_each_console(c) {
if (!strcmp(c->name, "tty") && c->index == 0)
break;
}
- console_unlock();
- if (c) {
- unregister_console(c);
- c->flags |= CON_CONSDEV;
- c->flags &= ~CON_PRINTBUFFER; /* don't print again */
- register_console(c);
- }
+ if (c)
+ console_force_preferred_locked(c);
+ console_list_unlock();
}
static int xenfb_resume(struct xenbus_device *dev)