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: <1962615c-d606-2e93-d256-47f15e1b1035@st.com>
Date:   Mon, 17 Jul 2017 11:56:13 +0200
From:   Ludovic BARRE <ludovic.barre@...com>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>,
        Cyrille Pitchen <cyrille.pitchen@...ev4u.fr>,
        Marek Vasut <marek.vasut@...il.com>,
        David Woodhouse <dwmw2@...radead.org>,
        Brian Norris <computersforpeace@...il.com>,
        Boris Brezillon <boris.brezillon@...e-electrons.com>,
        Richard Weinberger <richard@....at>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>
CC:     Arnd Bergmann <arnd@...db.de>, <linux-mtd@...ts.infradead.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: spi-nor: stm32-quadspi: Fix uninitialized error
 return code

Hi Geert


Thanks for your remarks.

Today only write_reg could be call with len=0 (spi-nor.c: 
write_enable/disable, set_4byte, erase_chip)

But your remark make sense to prevent: gcc warning and framework 
evolution ...


-In stm32-quadspi.c transfer data is enabled if tx_data is true (some 
actions under this bool)

stm32_qspi_write_reg has already this protection with "!!(buf && len > 0);"

but we could extend this protection

-    cmd.tx_data = true;
+    cmd.tx_data = !!(len > 0);

In : stm32_qspi_read, stm32_qspi_write, stm32_qspi_read_reg

-And to avoid gcc warning: I prefer initialize "ret" in the beginning of 
function

-    int ret;
+    int ret = 0;

I tested this changes, and it's ok for me.

Geert could you resend a new version, or do you prefer that I take care 
of it


BR
Ludo

On 07/15/2017 10:00 AM, Geert Uytterhoeven wrote:
> With gcc 4.1.2:
>
>      drivers/mtd/spi-nor/stm32-quadspi.c: In function ‘stm32_qspi_tx_poll’:
>      drivers/mtd/spi-nor/stm32-quadspi.c:230: warning: ‘ret’ may be used uninitialized in this function
>
> Indeed, if stm32_qspi_cmd.len is zero, ret will be uninitialized.
> This length is passed from outside the driver using the
> spi_nor.{read,write}{,_reg}() callbacks.
>
> Several functions in drivers/mtd/spi-nor/spi-nor.c (e.g. write_enable(),
> write_disable(), and erase_chip()) call spi_nor.write_reg() with a zero
> length.
>
> Fix this by returning an explicit zero on success.
>
> Fixes: 0d43d7ab277a048c ("mtd: spi-nor: add driver for STM32 quad spi flash controller")
> Signed-off-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> ---
>   drivers/mtd/spi-nor/stm32-quadspi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c
> index 86c0931543c538c3..ad6a3e1844cbe5ec 100644
> --- a/drivers/mtd/spi-nor/stm32-quadspi.c
> +++ b/drivers/mtd/spi-nor/stm32-quadspi.c
> @@ -240,12 +240,12 @@ static int stm32_qspi_tx_poll(struct stm32_qspi *qspi,
>   						 STM32_QSPI_FIFO_TIMEOUT_US);
>   		if (ret) {
>   			dev_err(qspi->dev, "fifo timeout (stat:%#x)\n", sr);
> -			break;
> +			return ret;
>   		}
>   		tx_fifo(buf++, qspi->io_base + QUADSPI_DR);
>   	}
>   
> -	return ret;
> +	return 0;
>   }
>   
>   static int stm32_qspi_tx_mm(struct stm32_qspi *qspi,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ