aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2012-07-14 10:31:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-16 16:00:41 -0400
commitadc8d746caa67fff4b53ba3e5163a6cbacc3b523 (patch)
treee3f6c05f27c163b369ddd4da5f31d2a61bde6d3a /drivers/tty/pty.c
parent6d31a88cb2e01d46c0cb74aa5da529e1f92ae3db (diff)
tty: move the termios object into the tty
This will let us sort out a whole pile of tty related races. The alternative would be to keep points and refcount the termios objects. However 1. They are tiny anyway 2. Many devices don't use the stored copies 3. We can remove a pty special case Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index b50fc1c01415..5ad7ccc49f74 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -231,8 +231,8 @@ out:
231static void pty_set_termios(struct tty_struct *tty, 231static void pty_set_termios(struct tty_struct *tty,
232 struct ktermios *old_termios) 232 struct ktermios *old_termios)
233{ 233{
234 tty->termios->c_cflag &= ~(CSIZE | PARENB); 234 tty->termios.c_cflag &= ~(CSIZE | PARENB);
235 tty->termios->c_cflag |= (CS8 | CREAD); 235 tty->termios.c_cflag |= (CS8 | CREAD);
236} 236}
237 237
238/** 238/**
@@ -315,18 +315,10 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
315 driver->other->ttys[idx] = o_tty; 315 driver->other->ttys[idx] = o_tty;
316 driver->ttys[idx] = tty; 316 driver->ttys[idx] = tty;
317 } else { 317 } else {
318 tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); 318 memset(&tty->termios_locked, 0, sizeof(tty->termios_locked));
319 if (tty->termios == NULL) 319 tty->termios = driver->init_termios;
320 goto err_deinit_tty; 320 memset(&o_tty->termios_locked, 0, sizeof(tty->termios_locked));
321 *tty->termios = driver->init_termios; 321 o_tty->termios = driver->other->init_termios;
322 tty->termios_locked = tty->termios + 1;
323
324 o_tty->termios = kzalloc(sizeof(struct ktermios[2]),
325 GFP_KERNEL);
326 if (o_tty->termios == NULL)
327 goto err_free_termios;
328 *o_tty->termios = driver->other->init_termios;
329 o_tty->termios_locked = o_tty->termios + 1;
330 } 322 }
331 323
332 /* 324 /*
@@ -349,8 +341,6 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
349err_free_termios: 341err_free_termios:
350 if (legacy) 342 if (legacy)
351 tty_free_termios(tty); 343 tty_free_termios(tty);
352 else
353 kfree(tty->termios);
354err_deinit_tty: 344err_deinit_tty:
355 deinitialize_tty_struct(o_tty); 345 deinitialize_tty_struct(o_tty);
356 module_put(o_tty->driver->owner); 346 module_put(o_tty->driver->owner);
@@ -541,7 +531,6 @@ static void pty_unix98_shutdown(struct tty_struct *tty)
541{ 531{
542 tty_driver_remove_tty(tty->driver, tty); 532 tty_driver_remove_tty(tty->driver, tty);
543 /* We have our own method as we don't use the tty index */ 533 /* We have our own method as we don't use the tty index */
544 kfree(tty->termios);
545} 534}
546 535
547/* We have no need to install and remove our tty objects as devpts does all 536/* We have no need to install and remove our tty objects as devpts does all