Re: [PATCH 2/2] tty/serial: atmel: check for pdata being NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/06/2017 11:30, Uwe Kleine-König wrote:
> 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)
> 

In patch https://www.mail-archive.com/linux-kernel@xxxxxxxxxxxxxxx/msg1420769.html
Alexandre got rid of pdata altogether, so I guess the inconsistency will gone with pdata :)

Richard.
--
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



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux