提交 0b479d54 编写于 作者: J Jiri Slaby 提交者: Greg Kroah-Hartman

TTY: pdc_cons, fix open vs pdc_console_tty_driver race

Assign the pointer to pdc_console_tty_driver (a tty_driver) earlier.
Otherwise the timer may dereference NULL.
Signed-off-by: NJiri Slaby <jslaby@suse.cz>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 52b762f7
...@@ -160,9 +160,7 @@ static void pdc_console_poll(unsigned long unused) ...@@ -160,9 +160,7 @@ static void pdc_console_poll(unsigned long unused)
static int __init pdc_console_tty_driver_init(void) static int __init pdc_console_tty_driver_init(void)
{ {
int err; int err;
struct tty_driver *drv;
/* Check if the console driver is still registered. /* Check if the console driver is still registered.
* It is unregistered if the pdc console was not selected as the * It is unregistered if the pdc console was not selected as the
...@@ -184,28 +182,27 @@ static int __init pdc_console_tty_driver_init(void) ...@@ -184,28 +182,27 @@ static int __init pdc_console_tty_driver_init(void)
printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
pdc_cons.flags &= ~CON_BOOT; pdc_cons.flags &= ~CON_BOOT;
drv = alloc_tty_driver(1); pdc_console_tty_driver = alloc_tty_driver(1);
if (!drv) if (!pdc_console_tty_driver)
return -ENOMEM; return -ENOMEM;
drv->driver_name = "pdc_cons"; pdc_console_tty_driver->driver_name = "pdc_cons";
drv->name = "ttyB"; pdc_console_tty_driver->name = "ttyB";
drv->major = MUX_MAJOR; pdc_console_tty_driver->major = MUX_MAJOR;
drv->minor_start = 0; pdc_console_tty_driver->minor_start = 0;
drv->type = TTY_DRIVER_TYPE_SYSTEM; pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
drv->init_termios = tty_std_termios; pdc_console_tty_driver->init_termios = tty_std_termios;
drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW |
tty_set_operations(drv, &pdc_console_tty_ops); TTY_DRIVER_RESET_TERMIOS;
tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops);
err = tty_register_driver(drv);
err = tty_register_driver(pdc_console_tty_driver);
if (err) { if (err) {
printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
return err; return err;
} }
pdc_console_tty_driver = drv;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册