Skip to content

Commit

Permalink
serial: 8250: fix return error code in serial8250_request_std_resource()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yi Yang authored and Greg Kroah-Hartman committed Jun 30, 2022
1 parent 5c5f44e commit 6e690d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/tty/serial/8250/8250_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6e690d5

Please sign in to comment.