aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-23 15:23:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-23 15:23:20 -0400
commit99dff5856220a02b8711f2e8746413ea6e53ccf6 (patch)
treed8bae7ccdf8f7ad5221b053bb74a6220df996b3a /drivers/tty/pty.c
parentbb74e8ca352eecefdc5c1a9ebab01f18aa2f6f3c (diff)
parentd9a0fbfd7bc5d2c42f0fa9bcbdab62c4942d0388 (diff)
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (48 commits) serial: 8250_pci: add support for Cronyx Omega PCI multiserial board. tty/serial: Fix break handling for PORT_TEGRA tty/serial: Add explicit PORT_TEGRA type n_tracerouter and n_tracesink ldisc additions. Intel PTI implementaiton of MIPI 1149.7. Kernel documentation for the PTI feature. export kernel call get_task_comm(). tty: Remove to support serial for S5P6442 pch_phub: Support new device ML7223 8250_pci: Add support for the Digi/IBM PCIe 2-port Adapter ASoC: Update cx20442 for TTY API change pch_uart: Support new device ML7223 IOH parport: Use request_muxed_region for IT87 probe and lock tty/serial: add support for Xilinx PS UART n_gsm: Use print_hex_dump_bytes drivers/tty/moxa.c: Put correct tty value TTY: tty_io, annotate locking functions TTY: serial_core, remove superfluous set_task_state TTY: serial_core, remove invalid test Char: moxa, fix locking in moxa_write ... Fix up trivial conflicts in drivers/bluetooth/hci_ldisc.c and drivers/tty/serial/Makefile. I did the hci_ldisc thing as an evil merge, cleaning things up.
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 210774726add..98b6e3bdb000 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/drivers/char/pty.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds 2 * Copyright (C) 1991, 1992 Linus Torvalds
5 * 3 *
6 * Added support for a Unix98-style ptmx device. 4 * Added support for a Unix98-style ptmx device.
@@ -295,8 +293,8 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
295 return -ENOMEM; 293 return -ENOMEM;
296 if (!try_module_get(driver->other->owner)) { 294 if (!try_module_get(driver->other->owner)) {
297 /* This cannot in fact currently happen */ 295 /* This cannot in fact currently happen */
298 free_tty_struct(o_tty); 296 retval = -ENOMEM;
299 return -ENOMEM; 297 goto err_free_tty;
300 } 298 }
301 initialize_tty_struct(o_tty, driver->other, idx); 299 initialize_tty_struct(o_tty, driver->other, idx);
302 300
@@ -304,13 +302,11 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
304 the easy way .. */ 302 the easy way .. */
305 retval = tty_init_termios(tty); 303 retval = tty_init_termios(tty);
306 if (retval) 304 if (retval)
307 goto free_mem_out; 305 goto err_deinit_tty;
308 306
309 retval = tty_init_termios(o_tty); 307 retval = tty_init_termios(o_tty);
310 if (retval) { 308 if (retval)
311 tty_free_termios(tty); 309 goto err_free_termios;
312 goto free_mem_out;
313 }
314 310
315 /* 311 /*
316 * Everything allocated ... set up the o_tty structure. 312 * Everything allocated ... set up the o_tty structure.
@@ -327,10 +323,14 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty)
327 tty->count++; 323 tty->count++;
328 driver->ttys[idx] = tty; 324 driver->ttys[idx] = tty;
329 return 0; 325 return 0;
330free_mem_out: 326err_free_termios:
327 tty_free_termios(tty);
328err_deinit_tty:
329 deinitialize_tty_struct(o_tty);
331 module_put(o_tty->driver->owner); 330 module_put(o_tty->driver->owner);
331err_free_tty:
332 free_tty_struct(o_tty); 332 free_tty_struct(o_tty);
333 return -ENOMEM; 333 return retval;
334} 334}
335 335
336static int pty_bsd_ioctl(struct tty_struct *tty, 336static int pty_bsd_ioctl(struct tty_struct *tty,
@@ -559,20 +559,19 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
559 return -ENOMEM; 559 return -ENOMEM;
560 if (!try_module_get(driver->other->owner)) { 560 if (!try_module_get(driver->other->owner)) {
561 /* This cannot in fact currently happen */ 561 /* This cannot in fact currently happen */
562 free_tty_struct(o_tty); 562 goto err_free_tty;
563 return -ENOMEM;
564 } 563 }
565 initialize_tty_struct(o_tty, driver->other, idx); 564 initialize_tty_struct(o_tty, driver->other, idx);
566 565
567 tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); 566 tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
568 if (tty->termios == NULL) 567 if (tty->termios == NULL)
569 goto free_mem_out; 568 goto err_free_mem;
570 *tty->termios = driver->init_termios; 569 *tty->termios = driver->init_termios;
571 tty->termios_locked = tty->termios + 1; 570 tty->termios_locked = tty->termios + 1;
572 571
573 o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL); 572 o_tty->termios = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
574 if (o_tty->termios == NULL) 573 if (o_tty->termios == NULL)
575 goto free_mem_out; 574 goto err_free_mem;
576 *o_tty->termios = driver->other->init_termios; 575 *o_tty->termios = driver->other->init_termios;
577 o_tty->termios_locked = o_tty->termios + 1; 576 o_tty->termios_locked = o_tty->termios + 1;
578 577
@@ -591,11 +590,13 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty)
591 tty->count++; 590 tty->count++;
592 pty_count++; 591 pty_count++;
593 return 0; 592 return 0;
594free_mem_out: 593err_free_mem:
594 deinitialize_tty_struct(o_tty);
595 kfree(o_tty->termios); 595 kfree(o_tty->termios);
596 kfree(tty->termios);
596 module_put(o_tty->driver->owner); 597 module_put(o_tty->driver->owner);
598err_free_tty:
597 free_tty_struct(o_tty); 599 free_tty_struct(o_tty);
598 kfree(tty->termios);
599 return -ENOMEM; 600 return -ENOMEM;
600} 601}
601 602