Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Linus Torvalds
8dff04ea 335adde6

+7 -11
+7 -11
drivers/char/pty.c
··· 488 488 { 489 489 /* We have our own method as we don't use the tty index */ 490 490 kfree(tty->termios); 491 - kfree(tty->termios_locked); 492 491 } 493 492 494 493 /* We have no need to install and remove our tty objects as devpts does all ··· 508 509 } 509 510 initialize_tty_struct(o_tty, driver->other, idx); 510 511 511 - tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL); 512 + tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); 512 513 if (tty->termios == NULL) 513 514 goto free_mem_out; 514 515 *tty->termios = driver->init_termios; 515 - tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); 516 - if (tty->termios_locked == NULL) 517 - goto free_mem_out; 518 - o_tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL); 516 + tty->termios_locked = tty->termios + 1; 517 + 518 + o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); 519 519 if (o_tty->termios == NULL) 520 520 goto free_mem_out; 521 521 *o_tty->termios = driver->other->init_termios; 522 - o_tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL); 523 - if (o_tty->termios_locked == NULL) 524 - goto free_mem_out; 522 + o_tty->termios_locked = o_tty->termios + 1; 525 523 526 524 tty_driver_kref_get(driver->other); 527 525 if (driver->subtype == PTY_TYPE_MASTER) ··· 536 540 pty_count++; 537 541 return 0; 538 542 free_mem_out: 539 - pty_unix98_shutdown(o_tty); 543 + kfree(o_tty->termios); 540 544 module_put(o_tty->driver->owner); 541 545 free_tty_struct(o_tty); 542 - pty_unix98_shutdown(tty); 546 + kfree(tty->termios); 543 547 return -ENOMEM; 544 548 } 545 549