diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:52:52 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 15:51:13 -0500 |
commit | 0b479d54ae7b79f62f09ef977c2228e579924d38 (patch) | |
tree | 9bd7a2790bf9776130bb1cc5aff80bafa2a445ec /arch/parisc/kernel | |
parent | 52b762f7a94c88e5a8aa2be67a06a6f01020cc82 (diff) |
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: Jiri 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/parisc/kernel')
-rw-r--r-- | arch/parisc/kernel/pdc_cons.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 8ad05215d4b1..d14e20fc60df 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c | |||
@@ -160,9 +160,7 @@ static void pdc_console_poll(unsigned long unused) | |||
160 | 160 | ||
161 | static int __init pdc_console_tty_driver_init(void) | 161 | static int __init pdc_console_tty_driver_init(void) |
162 | { | 162 | { |
163 | |||
164 | int err; | 163 | int err; |
165 | struct tty_driver *drv; | ||
166 | 164 | ||
167 | /* Check if the console driver is still registered. | 165 | /* Check if the console driver is still registered. |
168 | * It is unregistered if the pdc console was not selected as the | 166 | * 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 | printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); | 182 | printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); |
185 | pdc_cons.flags &= ~CON_BOOT; | 183 | pdc_cons.flags &= ~CON_BOOT; |
186 | 184 | ||
187 | drv = alloc_tty_driver(1); | 185 | pdc_console_tty_driver = alloc_tty_driver(1); |
188 | 186 | ||
189 | if (!drv) | 187 | if (!pdc_console_tty_driver) |
190 | return -ENOMEM; | 188 | return -ENOMEM; |
191 | 189 | ||
192 | drv->driver_name = "pdc_cons"; | 190 | pdc_console_tty_driver->driver_name = "pdc_cons"; |
193 | drv->name = "ttyB"; | 191 | pdc_console_tty_driver->name = "ttyB"; |
194 | drv->major = MUX_MAJOR; | 192 | pdc_console_tty_driver->major = MUX_MAJOR; |
195 | drv->minor_start = 0; | 193 | pdc_console_tty_driver->minor_start = 0; |
196 | drv->type = TTY_DRIVER_TYPE_SYSTEM; | 194 | pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; |
197 | drv->init_termios = tty_std_termios; | 195 | pdc_console_tty_driver->init_termios = tty_std_termios; |
198 | drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; | 196 | pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW | |
199 | tty_set_operations(drv, &pdc_console_tty_ops); | 197 | TTY_DRIVER_RESET_TERMIOS; |
200 | 198 | tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops); | |
201 | err = tty_register_driver(drv); | 199 | |
200 | err = tty_register_driver(pdc_console_tty_driver); | ||
202 | if (err) { | 201 | if (err) { |
203 | printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); | 202 | printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); |
204 | return err; | 203 | return err; |
205 | } | 204 | } |
206 | 205 | ||
207 | pdc_console_tty_driver = drv; | ||
208 | |||
209 | return 0; | 206 | return 0; |
210 | } | 207 | } |
211 | 208 | ||