diff --git a/include/linux/tty.h b/include/linux/tty.h index 90b4fdc8a61f14fcd8753bc5d7d55d89924e9302..4781d7b27dd39d9930164592d008aa1ac22772c3 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -518,9 +518,9 @@ extern void tty_port_put(struct tty_port *port); static inline struct tty_port *tty_port_get(struct tty_port *port) { - if (port) - kref_get(&port->kref); - return port; + if (port && kref_get_unless_zero(&port->kref)) + return port; + return NULL; } /* If the cts flow control is enabled, return true. */