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)
commitaee5da7838787f8ed47f825dbe09e2812acdf97b
tree993f2865f8971801be62985ee3b4fa8dd729bfaa
parentd3ba126a226a6b6da021ebfea444a2a807cde945
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: bed35c6dfa6a ("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