staging: greybus: uart: fix tty use after free
authorJohan Hovold <johan@kernel.org>
Mon, 6 Sep 2021 12:45:38 +0000 (14:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Oct 2021 08:23:39 +0000 (10:23 +0200)
commit92b67aaafb7c449db9f0c3dcabc0ff967cb3a42d
tree326f2157caf5a903112e35950e45f82ed6b08c46
parentdf8ae5e41319e37b6a3e7389f918d30b8478954a
staging: greybus: uart: fix tty use after free

commit 92dc0b1f46e12cfabd28d709bb34f7a39431b44f upstream.

User space can hold a tty open indefinitely and tty drivers must not
release the underlying structures until the last user is gone.

Switch to using the tty-port reference counter to manage the life time
of the greybus tty state to avoid use after free after a disconnect.

Fixes: a18e15175708 ("greybus: more uart work")
Cc: stable@vger.kernel.org # 4.9
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210906124538.22358-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/uart.c