• P
    tty: Fix ref counting for port krefs · c0fdfb80
    Peter Hurley 提交于
    The tty core supports two models for handling tty_port lifetimes;
    the tty_port can use the kref supplied by tty_port (which will
    automatically destruct the tty_port when the ref count drops to
    zero) or it can destruct the tty_port manually.
    
    For tty drivers that choose to use the port kref to manage the
    tty_port lifetime, it is not possible to safely acquire a port
    reference conditionally. If the last reference is released after
    evaluating the condition but before acquiring the reference, a
    bogus reference will be held while the tty_port destruction
    commences.
    
    Rather, only acquire a port reference if the ref count is non-zero
    and allow the caller to distinguish if a reference has successfully
    been acquired.
    
    Cc: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
    Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Tested-By: NAlexander Holler <holler@ahsoftware.de>
    Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
    c0fdfb80
tty.h 24.3 KB