• Johan Hovold's avatar
    serdev: fix tty-port client deregistration · aee5da78
    Johan Hovold authored
    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: bed35c6d ("serdev: add a tty port controller driver")
    Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
    Reviewed-by: default avatarRob Herring <robh@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    aee5da78
serdev-ttyport.c 6.91 KB