]> git.baikalelectronics.ru Git - kernel.git/commit
serdev: fix tty-port client deregistration
authorJohan Hovold <johan@kernel.org>
Tue, 11 Apr 2017 17:07:29 +0000 (19:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 May 2017 14:41:49 +0000 (16:41 +0200)
commita6ef82c73c7e6fd3976f15da89fc0e6a26926ab5
tree993f2865f8971801be62985ee3b4fa8dd729bfaa
parent61d147449b740bd219710022ec338316535c9495
serdev: fix tty-port client deregistration

The port client data must be set when registering the serdev controller
or client deregistration will fail (and the serdev devices are left
registered and allocated) if the port was never opened in between.

Make sure to clear the port client data on any probe errors to avoid a
use-after-free when the client is later deregistered unconditionally
(e.g. in a tty-port deregistration helper).

Also move port client operation initialisation to registration. Note
that the client ops must be restored on failed probe.

Fixes: 24aea4fff7d4 ("serdev: add a tty port controller driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serdev/serdev-ttyport.c