]> git.baikalelectronics.ru Git - kernel.git/commit
tty: Fix the leak in tty_ldisc_release
authorAlan Cox <alan@linux.intel.com>
Mon, 29 Jun 2009 14:21:47 +0000 (15:21 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 29 Jun 2009 16:33:26 +0000 (09:33 -0700)
commit87c2c4a88fde41f44c9896a970ab18d643f5cf28
tree2fd190b9fb78504adbb7e1fdf902ad9f682633bc
parenta3486f3f37e2b4819a026183d39e80253c3caafc
tty: Fix the leak in tty_ldisc_release

Currently we reinit the ldisc on final tty close which is what the old code
did to ensure that if the device retained its termios settings then it had the
right ldisc. tty_ldisc_reinit does that but also leaves us with the reset
ldisc reference which is then leaked.

At this point we know the port will be recycled so we can kill the ldisc
off completely rather than try and add another ldisc free up when the kref
count hits zero.

At this point it is safe to keep the ldisc closed as tty_ldisc waiting
methods are only used from the user side, and as the final close we are
the last such reference. Interrupt/driver side methods will always use the
non wait version and get back a NULL.

Found with kmemleak and investigated/identified by Catalin Marinas.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/tty_ldisc.c