lkml.org 
[lkml]   [2019]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC][PATCH 2/2] printk: take console_sem when accessing console drivers list
On (04/25/19 14:19), Sergey Senozhatsky wrote:
>
> So may be we can move the whole thing under console_sem.
>

Something like below. I'll re-spin the series in a day or two,
we have time.

---
kernel/printk/printk.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 52d1123d9fdc..0c2eb161e793 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2666,7 +2666,7 @@ static int __unregister_console(struct console *console)
* - Once a "real" console is registered, any attempt to register a
* bootconsoles will be rejected
*/
-void register_console(struct console *newcon)
+static void __register_console(struct console *newcon)
{
int i;
unsigned long flags;
@@ -2771,7 +2771,6 @@ void register_console(struct console *newcon)
* Put this console in the list - keep the
* preferred driver at the head of the list.
*/
- console_lock();
if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
newcon->next = console_drivers;
console_drivers = newcon;
@@ -2820,19 +2819,25 @@ void register_console(struct console *newcon)

console_unlock();
console_sysfs_notify();
+ console_lock();

if (keep_bootcon)
return;

if (bcon && (newcon->flags & (CON_CONSDEV|CON_BOOT)) == CON_CONSDEV) {
- console_lock();
for_each_console(bcon)
if (bcon->flags & CON_BOOT)
__unregister_console(bcon);
- console_unlock();
- console_sysfs_notify();
}
}
+
+void register_console(struct console *newcon)
+{
+ console_lock();
+ __register_console(newcon);
+ console_unlock();
+ console_sysfs_notify();
+}
EXPORT_SYMBOL(register_console);

int unregister_console(struct console *console)
--
2.21.0
\
 
 \ /
  Last update: 2019-04-25 08:48    [W:2.178 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site