aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:43:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:44 -0400
commit8dff04ea316125639120c0a565ce0346b892fef7 (patch)
treef6c4d0455d951d550ab55cebe109ac526c957011 /drivers
parent335adde689150d2fcf4df3cb26a6fc6740ed1f3e (diff)
pty: simplify unix98 allocation
We need both termios and termios_locked so allocate them as one Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/pty.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 3c6b7911665f..6d4582712b1f 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -488,7 +488,6 @@ static void pty_unix98_shutdown(struct tty_struct *tty)
488{ 488{
489 /* We have our own method as we don't use the tty index */ 489 /* We have our own method as we don't use the tty index */
490 kfree(tty->termios); 490 kfree(tty->termios);
491 kfree(tty->termios_locked);
492} 491}
493 492
494/* We have no need to install and remove our tty objects as devpts does all 493/* We have no need to install and remove our tty objects as devpts does all
@@ -509,20 +508,17 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
509 } 508 }
510 initialize_tty_struct(o_tty, driver->other, idx); 509 initialize_tty_struct(o_tty, driver->other, idx);
511 510
512 tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL); 511 tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
513 if (tty->termios == NULL) 512 if (tty->termios == NULL)
514 goto free_mem_out; 513 goto free_mem_out;
515 *tty->termios = driver->init_termios; 514 *tty->termios = driver->init_termios;
516 tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); 515 tty->termios_locked = tty->termios + 1;
517 if (tty->termios_locked == NULL) 516
518 goto free_mem_out; 517 o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
519 o_tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
520 if (o_tty->termios == NULL) 518 if (o_tty->termios == NULL)
521 goto free_mem_out; 519 goto free_mem_out;
522 *o_tty->termios = driver->other->init_termios; 520 *o_tty->termios = driver->other->init_termios;
523 o_tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); 521 o_tty->termios_locked = o_tty->termios + 1;
524 if (o_tty->termios_locked == NULL)
525 goto free_mem_out;
526 522
527 tty_driver_kref_get(driver->other); 523 tty_driver_kref_get(driver->other);
528 if (driver->subtype == PTY_TYPE_MASTER) 524 if (driver->subtype == PTY_TYPE_MASTER)
@@ -540,10 +536,10 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
540 pty_count++; 536 pty_count++;
541 return 0; 537 return 0;
542free_mem_out: 538free_mem_out:
543 pty_unix98_shutdown(o_tty); 539 kfree(o_tty->termios);
544 module_put(o_tty->driver->owner); 540 module_put(o_tty->driver->owner);
545 free_tty_struct(o_tty); 541 free_tty_struct(o_tty);
546 pty_unix98_shutdown(tty); 542 kfree(tty->termios);
547 return -ENOMEM; 543 return -ENOMEM;
548} 544}
549 545