diff options
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r-- | drivers/tty/pty.c | 35 |
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; |
330 | free_mem_out: | 326 | err_free_termios: |
327 | tty_free_termios(tty); | ||
328 | err_deinit_tty: | ||
329 | deinitialize_tty_struct(o_tty); | ||
331 | module_put(o_tty->driver->owner); | 330 | module_put(o_tty->driver->owner); |
331 | err_free_tty: | ||
332 | free_tty_struct(o_tty); | 332 | free_tty_struct(o_tty); |
333 | return -ENOMEM; | 333 | return retval; |
334 | } | 334 | } |
335 | 335 | ||
336 | static int pty_bsd_ioctl(struct tty_struct *tty, | 336 | static 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; |
594 | free_mem_out: | 593 | err_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); |
598 | err_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 | ||