[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220628083515.64138-1-yiyang13@huawei.com>
Date: Tue, 28 Jun 2022 16:35:15 +0800
From: Yi Yang <yiyang13@...wei.com>
To: <gregkh@...uxfoundation.org>, <jirislaby@...nel.org>,
<ilpo.jarvinen@...ux.intel.com>, <andy.shevchenko@...il.com>
CC: <linux-serial@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 -next] serial: 8250: fix return error code in serial8250_request_std_resource()
If port->mapbase = NULL in serial8250_request_std_resource() , it need
return a error code instead of 0. If uart_set_info() fail to request new
regions by serial8250_request_std_resource() but the return value of
serial8250_request_std_resource() is 0, The system incorrectly considers
that the resource application is successful and does not attempt to
restore the old setting. A null pointer reference is triggered when the
port resource is later invoked.
Signed-off-by: Yi Yang <yiyang13@...wei.com>
---
v2:
- return EINVAL instead of EFAULT.
- change commit messge.
drivers/tty/serial/8250/8250_port.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3e3d784aa628..20b47355221b 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2961,8 +2961,10 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
case UPIO_MEM32BE:
case UPIO_MEM16:
case UPIO_MEM:
- if (!port->mapbase)
+ if (!port->mapbase) {
+ ret = -EINVAL;
break;
+ }
if (!request_mem_region(port->mapbase, size, "serial")) {
ret = -EBUSY;
--
2.17.1
Powered by blists - more mailing lists