Most functions in the atmel serial driver check for pdata being non-NULL before making use of it, atmel_init_property and atmel_init_rs485() don't. Probably this isn't a big problem because devices that are not probed from device tree relied on this before 5fbe46b67680 ("tty/serial: atmel_serial: add device tree support") (contained in v3.2-rc1) and I guess since then the platform devices didn't change much. Make this consistent and safe anyhow. I didn't see (or try to find) a platform crashing here, only noticed this inconsistency while working on this driver. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> --- drivers/tty/serial/atmel_serial.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 906e2b91bf57..b753d2020068 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1686,8 +1686,13 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port, } } else { - atmel_port->use_pdc_rx = pdata->use_dma_rx; - atmel_port->use_pdc_tx = pdata->use_dma_tx; + if (pdata) { + atmel_port->use_pdc_rx = pdata->use_dma_rx; + atmel_port->use_pdc_tx = pdata->use_dma_tx; + } else { + atmel_port->use_pdc_rx = false; + atmel_port->use_pdc_tx = false; + } atmel_port->use_dma_rx = false; atmel_port->use_dma_tx = false; } @@ -1717,10 +1722,13 @@ static void atmel_init_rs485(struct uart_port *port, if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL)) rs485conf->flags |= SER_RS485_ENABLED; + } else if (pdata) { + port->rs485 = pdata->rs485; } else { - port->rs485 = pdata->rs485; - } + struct serial_rs485 default_rs485 = { 0, }; + port->rs485 = default_rs485; + } } static void atmel_set_ops(struct uart_port *port) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html