aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorYi Yang <yiyang13@huawei.com>2022-06-28 16:35:15 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-30 17:15:47 +0200
commit6e690d54cfa802f939cefbd2fa2c91bd0b8bd1b6 (patch)
tree2166f2337e0a8dca5b8275fa17c3f8064922d79f /drivers/tty/serial
parentserial: stm32: Clear prev values before setting RTS delays (diff)
downloadlinux-dev-6e690d54cfa802f939cefbd2fa2c91bd0b8bd1b6.tar.xz
linux-dev-6e690d54cfa802f939cefbd2fa2c91bd0b8bd1b6.zip
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@huawei.com> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/r/20220628083515.64138-1-yiyang13@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/8250/8250_port.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index b9cdc5552b0d..3c36a06a20b0 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2975,8 +2975,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;