lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <75c0cbd4-7cec-a415-bfba-376f035f76@linux.intel.com>
Date: Wed, 3 Jan 2024 13:19:43 +0200 (EET)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Lino Sanfilippo <l.sanfilippo@...bus.com>
cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
    Jiri Slaby <jirislaby@...nel.org>, u.kleine-koenig@...gutronix.de, 
    shawnguo@...nel.org, s.hauer@...gutronix.de, mcoquelin.stm32@...il.com, 
    alexandre.torgue@...s.st.com, cniedermaier@...electronics.com, 
    hugo@...ovil.com, m.brock@...mierlo.com, 
    LKML <linux-kernel@...r.kernel.org>, 
    linux-serial <linux-serial@...r.kernel.org>, LinoSanfilippo@....de, 
    Lukas Wunner <lukas@...ner.de>, p.rosenberger@...bus.com, 
    stable@...r.kernel.org
Subject: Re: [PATCH v7 5/7] serial: core, imx: do not set RS485 enabled if
 it is not supported

On Wed, 3 Jan 2024, Lino Sanfilippo wrote:

> If the imx driver cannot support RS485 it nullifies the ports
> rs485_supported structure. But it still calls uart_get_rs485_mode() which
> may set the RS485_ENABLED flag nevertheless.
> 
> This may lead to an attempt to configure RS485 even if it is not supported
> when the flag is evaluated in uart_configure_port() at port startup.
> 
> Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED
> flag is not supported by the caller.
> 
> With this fix a check for RTS availability is now obsolete in the imx
> driver, since it can not evaluate to true any more. So remove this check.
> 
> Furthermore the explicit nullifcation of rs485_supported is not needed,
> since the memory has already been set to zeros at allocation. So remove
> this, too.
> 
> Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported")
> Cc: Shawn Guo <shawnguo@...nel.org>
> Cc: Sascha Hauer <s.hauer@...gutronix.de>
> Cc: stable@...r.kernel.org
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
> ---
>  drivers/tty/serial/imx.c         | 7 -------
>  drivers/tty/serial/serial_core.c | 3 +++
>  2 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 9cffeb23112b..198ce7e7bc8b 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2206,7 +2206,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t)
>  	return HRTIMER_NORESTART;
>  }
>  
> -static const struct serial_rs485 imx_no_rs485 = {};	/* No RS485 if no RTS */
>  static const struct serial_rs485 imx_rs485_supported = {
>  	.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND |
>  		 SER_RS485_RX_DURING_TX,
> @@ -2290,8 +2289,6 @@ static int imx_uart_probe(struct platform_device *pdev)
>  	/* RTS is required to control the RS485 transmitter */
>  	if (sport->have_rtscts || sport->have_rtsgpio)
>  		sport->port.rs485_supported = imx_rs485_supported;
> -	else
> -		sport->port.rs485_supported = imx_no_rs485;
>  	sport->port.flags = UPF_BOOT_AUTOCONF;
>  	timer_setup(&sport->timer, imx_uart_timeout, 0);
>  
> @@ -2328,10 +2325,6 @@ static int imx_uart_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	if (sport->port.rs485.flags & SER_RS485_ENABLED &&
> -	    (!sport->have_rtscts && !sport->have_rtsgpio))
> -		dev_err(&pdev->dev, "no RTS control, disabling rs485\n");
> -
>  	/*
>  	 * If using the i.MX UART RTS/CTS control then the RTS (CTS_B)
>  	 * signal cannot be set low during transmission in case the
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 28bcbc686c67..93e4e1693601 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3600,6 +3600,9 @@ int uart_get_rs485_mode(struct uart_port *port)
>  	u32 rs485_delay[2];
>  	int ret;
>  
> +	if (!(port->rs485_supported.flags & SER_RS485_ENABLED))
> +		return 0;
> +

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>

-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ