[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220823055739.1451419-1-floridsleeves@gmail.com>
Date: Mon, 22 Aug 2022 22:57:39 -0700
From: lily <floridsleeves@...il.com>
To: linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org,
lily <floridsleeves@...il.com>
Subject: [PATCH v1] drivers/tty/serial: check the return value of uart_port_check()
uart_port_check() can return NULL pointer. Check its return value
before dereference it.
Signed-off-by: Li Zhong <floridsleeves@...il.com>
---
drivers/tty/serial/serial_core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 12c87cd201a7..760e177166cf 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -194,6 +194,9 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
unsigned long page;
int retval = 0;
+ if (!uport)
+ return -EIO;
+
if (uport->type == PORT_UNKNOWN)
return 1;
@@ -498,6 +501,8 @@ static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
struct ktermios *termios;
int hw_stopped;
+ if (!uport)
+ return;
/*
* If we have no tty, termios, or the port does not exist,
* then we can't set the parameters for this port.
@@ -1045,6 +1050,8 @@ static int uart_get_lsr_info(struct tty_struct *tty,
struct uart_port *uport = uart_port_check(state);
unsigned int result;
+ if (!uport)
+ return -EIO;
result = uport->ops->tx_empty(uport);
/*
--
2.25.1
Powered by blists - more mailing lists