History

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.

Yi Yang committed 4 years ago

Commit 6e690d51 parent 5c5f44e1 file · +3 −1Browse files

Unified · Split

drivers/tty/serial/8250/8250_port.c+3−1
@@ -2975,8 +2975,10 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) · 2974 unmodified lines
2975 case UPIO_MEM32BE:2975 case UPIO_MEM32BE:
2976 case UPIO_MEM16:2976 case UPIO_MEM16:
2977 case UPIO_MEM:2977 case UPIO_MEM:
2978 if (!port->mapbase)2978 if (!port->mapbase) {
2979 ret = -EINVAL;
2979 break;2980 break;
2981 }
2980 2982
2981 if (!request_mem_region(port->mapbase, size, "serial")) {2983 if (!request_mem_region(port->mapbase, size, "serial")) {
2982 ret = -EBUSY;2984 ret = -EBUSY;