From: Andy Shevchenko Date: Fri, 4 Feb 2022 15:32:53 +0000 (+0200) Subject: tty: Drop duplicate NULL check in TTY port functions X-Git-Tag: v6.1-rc5~1690^2~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c5b2f5b9a829992f3760395a64d6102f11fe62d;p=platform%2Fkernel%2Flinux-starfive.git tty: Drop duplicate NULL check in TTY port functions The free_page(addr), which becomes free_pages(addr, 0) checks addr against 0. No need to repeat this check in the callers, i.e. tty_port_free_xmit_buf() and tty_port_destructor(). Note, INIT_KFIFO() is safe without that check, because it operates on a separate member and doesn't rely on the FIFO itself to be allocated. Acked-by: Jiri Slaby Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220204153253.11006-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 4282895..880608a 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -240,11 +240,9 @@ EXPORT_SYMBOL(tty_port_alloc_xmit_buf); void tty_port_free_xmit_buf(struct tty_port *port) { mutex_lock(&port->buf_mutex); - if (port->xmit_buf != NULL) { - free_page((unsigned long)port->xmit_buf); - port->xmit_buf = NULL; - INIT_KFIFO(port->xmit_fifo); - } + free_page((unsigned long)port->xmit_buf); + port->xmit_buf = NULL; + INIT_KFIFO(port->xmit_fifo); mutex_unlock(&port->buf_mutex); } EXPORT_SYMBOL(tty_port_free_xmit_buf); @@ -271,8 +269,7 @@ static void tty_port_destructor(struct kref *kref) /* check if last port ref was dropped before tty release */ if (WARN_ON(port->itty)) return; - if (port->xmit_buf) - free_page((unsigned long)port->xmit_buf); + free_page((unsigned long)port->xmit_buf); tty_port_destroy(port); if (port->ops && port->ops->destruct) port->ops->destruct(port);