Commit 8dff04ea316125639120c0a565ce0346b892fef7

Authored by Alan Cox
Committed by Linus Torvalds
1 parent 335adde689

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>

Showing 1 changed file with 7 additions and 11 deletions Side-by-side Diff

... ... @@ -488,7 +488,6 @@
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
495 494  
496 495  
... ... @@ -509,20 +508,17 @@
509 508 }
510 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 512 if (tty->termios == NULL)
514 513 goto free_mem_out;
515 514 *tty->termios = driver->init_termios;
516   - tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL);
517   - if (tty->termios_locked == NULL)
518   - goto free_mem_out;
519   - o_tty->termios = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
  515 + tty->termios_locked = tty->termios + 1;
  516 +
  517 + o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
520 518 if (o_tty->termios == NULL)
521 519 goto free_mem_out;
522 520 *o_tty->termios = driver->other->init_termios;
523   - o_tty->termios_locked = kzalloc(sizeof(struct ktermios), GFP_KERNEL);
524   - if (o_tty->termios_locked == NULL)
525   - goto free_mem_out;
  521 + o_tty->termios_locked = o_tty->termios + 1;
526 522  
527 523 tty_driver_kref_get(driver->other);
528 524 if (driver->subtype == PTY_TYPE_MASTER)
529 525  
... ... @@ -540,10 +536,10 @@
540 536 pty_count++;
541 537 return 0;
542 538 free_mem_out:
543   - pty_unix98_shutdown(o_tty);
  539 + kfree(o_tty->termios);
544 540 module_put(o_tty->driver->owner);
545 541 free_tty_struct(o_tty);
546   - pty_unix98_shutdown(tty);
  542 + kfree(tty->termios);
547 543 return -ENOMEM;
548 544 }
549 545