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: <87lel4hz5b.fsf@osv.gnss.ru>
Date:   Sat, 11 Feb 2023 20:48:00 +0300
From:   Sergey Organov <sorganov@...il.com>
To:     Tom Rix <trix@...hat.com>
Cc:     gregkh@...uxfoundation.org, jirislaby@...nel.org,
        shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
        festevam@...il.com, linux-imx@....com,
        linux-serial@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] serial: imx: remove a redundant check

Tom Rix <trix@...hat.com> writes:

> cpp_check reports
> drivers/tty/serial/imx.c:1207:15: style: Condition 'r_bytes>0' is always true [knownConditionTrueFalse]
>   if (r_bytes > 0) {
>
> r_byte is set to
>   r_bytes = rx_ring->head - rx_ring->tail;
>
> The head - tail calculation is also done by the earlier check
>   if (rx_ring->head <= sg_dma_len(sgl) &&
>       rx_ring->head > rx_ring->tail) {
>
> so r_bytes will always be > 0, so the second check is not needed.
>
> Signed-off-by: Tom Rix <trix@...hat.com>
> ---
>  drivers/tty/serial/imx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 363c77a140f0..523f296d5747 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1204,11 +1204,9 @@ static void imx_uart_dma_rx_callback(void *data)
>  		r_bytes = rx_ring->head - rx_ring->tail;
>  
>  		/* If we received something, check for 0xff flood */
> -		if (r_bytes > 0) {
> -			spin_lock(&sport->port.lock);
> -			imx_uart_check_flood(sport, imx_uart_readl(sport, USR2));
> -			spin_unlock(&sport->port.lock);
> -		}
> +		spin_lock(&sport->port.lock);
> +		imx_uart_check_flood(sport, imx_uart_readl(sport, USR2));
> +		spin_unlock(&sport->port.lock);
>  
>  		if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ))
>  		{

Nice catch. Didn't notice this when wrote the check-flood patch, sorry!

Thanks,
-- Sergey Organov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ