From patchwork Thu Sep 14 11:06:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9952849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25A8560230 for ; Thu, 14 Sep 2017 11:07:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2921428E92 for ; Thu, 14 Sep 2017 11:07:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CD7C28EB7; Thu, 14 Sep 2017 11:07:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C20A28E92 for ; Thu, 14 Sep 2017 11:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fwLKq2RtxOOQv824l391Nbw/4AzN/JuxqShA7wQHVQA=; b=RR06NPM8vCppD+ X2uaqoVjySci+9RrGkzM7gGSccbK/8gCZLrZeTxwoIiyZgo2TpP1Ia1hR1KJq7CUkZKJqhVzH8rjv Snb2e+d7og6FCGvwQTaJYCL5Mq4JDPwk5a/jQQ4UxiDeF2r7NYnb3uHsi39UjPA+YFFmX5r/q5q60 IVgvQ1jtAD8d5jTZsiVsqvJBSKNBX4upmzxCW92+JmKseOaADXVxwgWzMhOCsLX1kHlBw8Kvv28k0 Od3viIQ7CDoXOvctBe9dwMA9iSGDbqB1JIEvtPAjtZuZOZM02tVBlaKGbTFyWwb6tN2yzjVZUY07u hwyMz7Sa/j7xwLUmRQbg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dsRzm-0008WC-Kj; Thu, 14 Sep 2017 11:07:46 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dsRzh-0008Rs-Gd; Thu, 14 Sep 2017 11:07:44 +0000 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0M8zxV-1dio0L1MSL-00CNQw; Thu, 14 Sep 2017 13:07:12 +0200 From: Arnd Bergmann To: Cyrille Pitchen , Marek Vasut Subject: [PATCH] mtd: spi-nor: stm32-quadspi: avoid unintialized return code Date: Thu, 14 Sep 2017 13:06:59 +0200 Message-Id: <20170914110709.3591691-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:E8JqzB6AzgYnMvatpFTscg0rtb0LaZ1CTbyabfEhWsygsvbUk1s QPti6WnPk6Imy6vRXizNsfpgxVl3C816jKSQ1lNkvsRqEkXU8KGII559ugcFMRF3CZ9uZ/2 E86g7r980kJwj0nK7ILSfhwgsw0+XasADv6zUXVKr1Z4VjyZZACEOqiErTQL3ZVb3SVyKgk 6y+Qs6U90nOVsvdArir4A== X-UI-Out-Filterresults: notjunk:1; V01:K0:xp3DOooirCo=:4jNWEtnyEMQQhPLOug1VLW 5J9ITGFZE2GBVQO6BnZoLxjKHhTIrxR+daZ34qpUDU4bC4/Dmu3TJqUfuAgyllwesag2Vonao iafoRhV+girQ8qUt6iZ905A63TIkrL+Ra3dvFeOuG69jB6ogHhzDeEt7ZAAWHqCQbSUMiUoQt BLVuLx8eBitM/6+S53Fom3qwn3YiPUjuEHXQ8yoj6WjT88gqeb45hmO7JjChcWjJfk2V6Rgfh ZBIDqJkn3MT3yozCflHWcFyvF3JxwMiCMDFPil++0Bzll6q2yhLawUBXPvKIJQ6jGrsn+Scza Pse3ik7pSK8hcqhbd3qgZO8bKI2sVVei0jxz/HtR/nANhQA0PR+TQgQ0PVmakWC/tk47muU7Q Xx6OXVT3QNByI0F+Jj1sUM/9JbI0pjngT3q+pVeddYtAro+Oe7dF2BMV8yDEyKCMGQhWh75e7 CVyA2Bgg77Axw9aW5MRisWT758iUiNyDxBVnCmxpU/YY8x4gnjxgvEpeWPw6JG1Nt2udWfOCC lCOoW8aOiwyG4BrGXJAzve2RnKHTIiPb0LiF10/waE4JvF3jkf7qKghsW+SJf1YpN+YYs4jsw 6IMgb27fpRqYk6Aedz9Go9jk/Pvd3geqWoXIqLqWqTkkRHlwEqbDt+B2+ZeeXdj663gncnZdN Ku7BoPEvKoRiaZ/kj5fCdMYsAbS3cUe9AyIM+dWUm0FJhsa6AjO+ffmuY7c7E5gbq3hsKYS7P BorTRAaP+N9gvJpa9ZGpV7FtRBpVs6tUcXLwVbd8KdY+/YlGjt9la1ychso= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170914_040741_889367_7ED0D7B5 X-CRM114-Status: GOOD ( 11.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Alexandre Torgue , Arnd Bergmann , Richard Weinberger , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Maxime Coquelin , Brian Norris , David Woodhouse , Ludovic Barre Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If we send zero-length data to stm32_qspi_tx_poll() on older compiler versions such as gcc-4.6, we get warned that the return code is uninitialized: drivers/mtd/spi-nor/stm32-quadspi.c:248:2: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized] On newer compiler versions, the return code is always zero in this case, as the local variable gets optimized away and is assumed to be zero after the loop completes without error. This changes the function to instead return -EINVAL if it ever gets called with a zero length buffer. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203 Signed-off-by: Arnd Bergmann Acked-by: Ludovic Barre --- drivers/mtd/spi-nor/stm32-quadspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c index 86c0931543c5..711cfe7aa4bf 100644 --- a/drivers/mtd/spi-nor/stm32-quadspi.c +++ b/drivers/mtd/spi-nor/stm32-quadspi.c @@ -227,7 +227,7 @@ static int stm32_qspi_tx_poll(struct stm32_qspi *qspi, void (*tx_fifo)(u8 *, void __iomem *); u32 len = cmd->len, sr; u8 *buf = cmd->buf; - int ret; + int ret = -EINVAL; if (cmd->qspimode == CCR_FMODE_INDW) tx_fifo = stm32_qspi_write_fifo;