diff options
author | Jiri Slaby <jslaby@suse.cz> | 2011-03-23 05:48:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-19 17:43:01 -0400 |
commit | a9dccddb60913056bcadaeeacfe0395447fd2472 (patch) | |
tree | 8f1fccdba560437d52040677347e7c2f40c18626 /drivers/tty | |
parent | 6716671d8c1c07a8072098764d1b7cbfef7412ad (diff) |
TTY: plug in deinitialize_tty_struct
Used the newly introduced deinitialize_tty_struct to properly shut
down ldisc.
It is intended to fix the Julian's reported problem. He reports that
kmemleak checker warns about memory leak:
unreferenced object 0xc0e19860 (size 8):
comm cat, pid 1226, jiffies 4294919464 (age 287.476s)
hex dump (first 8 bytes):
44 de 2d c1 01 00 00 00 D.-.....
backtrace:
[<c1065a74>] create_object+0x109/0x1ad
[<c1063d2b>] kmem_cache_alloc+0x60/0x68
[<c113505c>] tty_ldisc_get+0x54/0x76
[<c11358c9>] tty_ldisc_init+0xa/0x20
[<c1130ab4>] initialize_tty_struct+0x2d/0x1ac
[<c1130c8c>] tty_init_dev+0x59/0x10d
[<c113136d>] tty_open+0x24a/0x3a2
...
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Reported-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/pty.c | 6 | ||||
-rw-r--r-- | drivers/tty/tty_io.c | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index b25d6c4014a5..21bddf359dbb 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -304,7 +304,7 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | |||
304 | the easy way .. */ | 304 | the easy way .. */ |
305 | retval = tty_init_termios(tty); | 305 | retval = tty_init_termios(tty); |
306 | if (retval) | 306 | if (retval) |
307 | goto err_module_put; | 307 | goto err_deinit_tty; |
308 | 308 | ||
309 | retval = tty_init_termios(o_tty); | 309 | retval = tty_init_termios(o_tty); |
310 | if (retval) | 310 | if (retval) |
@@ -327,7 +327,8 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | |||
327 | return 0; | 327 | return 0; |
328 | err_free_termios: | 328 | err_free_termios: |
329 | tty_free_termios(tty); | 329 | tty_free_termios(tty); |
330 | err_module_put: | 330 | err_deinit_tty: |
331 | deinitialize_tty_struct(o_tty); | ||
331 | module_put(o_tty->driver->owner); | 332 | module_put(o_tty->driver->owner); |
332 | err_free_tty: | 333 | err_free_tty: |
333 | free_tty_struct(o_tty); | 334 | free_tty_struct(o_tty); |
@@ -592,6 +593,7 @@ static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) | |||
592 | pty_count++; | 593 | pty_count++; |
593 | return 0; | 594 | return 0; |
594 | err_free_mem: | 595 | err_free_mem: |
596 | deinitialize_tty_struct(o_tty); | ||
595 | kfree(o_tty->termios); | 597 | kfree(o_tty->termios); |
596 | kfree(tty->termios); | 598 | kfree(tty->termios); |
597 | module_put(o_tty->driver->owner); | 599 | module_put(o_tty->driver->owner); |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index f5dd23520fe3..8540f2bab9c6 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -1399,7 +1399,7 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | |||
1399 | 1399 | ||
1400 | retval = tty_driver_install_tty(driver, tty); | 1400 | retval = tty_driver_install_tty(driver, tty); |
1401 | if (retval < 0) | 1401 | if (retval < 0) |
1402 | goto err_free_tty; | 1402 | goto err_deinit_tty; |
1403 | 1403 | ||
1404 | /* | 1404 | /* |
1405 | * Structures all installed ... call the ldisc open routines. | 1405 | * Structures all installed ... call the ldisc open routines. |
@@ -1411,7 +1411,8 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | |||
1411 | goto err_release_tty; | 1411 | goto err_release_tty; |
1412 | return tty; | 1412 | return tty; |
1413 | 1413 | ||
1414 | err_free_tty: | 1414 | err_deinit_tty: |
1415 | deinitialize_tty_struct(tty); | ||
1415 | free_tty_struct(tty); | 1416 | free_tty_struct(tty); |
1416 | err_module_put: | 1417 | err_module_put: |
1417 | module_put(driver->owner); | 1418 | module_put(driver->owner); |