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: 813785 X-Patchwork-Delegate: cyrille.pitchen@atmel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u9QvOy5/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xtG3z0v2cz9sMN for ; Thu, 14 Sep 2017 21:08:31 +1000 (AEST) 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=lohjy8WvJuuDWPy2N3VQ0Qo/ILECLuT5CqutwIIy71A=; b=u9QvOy5/ExQZBJ LBVVgW+18Z06GXYwLHLc0QeSmgn0lmWve2D19fSekbdvfTbO4cirHeOfCEQcZts30g3FQC4P2y06c /Mly7aFNI1OmSjeWjzU4Zz+DiU1fRD8i73ASjgLHYIMpTYFmv0H46+hVb8mA+SHV9lJXOZMMfIW1c nTlYAPsnQObhhhJClGRHWaMmnjz4EQCwBszocp1JLQ3CQAqGDYVbWNpNhnmhUGKcpc75Ujfbwn5FC x77h7ieQA3Kw832NGZ5bwMtwRNMN3lAEaiVOuQj3ilqY7LRkXzGF4OCv9vUhmW7So+TTMxmogJzVG x8scAHUwM/WQYH6hylXQ==; 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 1dsS04-0000JN-Rb; Thu, 14 Sep 2017 11:08:04 +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-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [217.72.192.74 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [217.72.192.74 listed in list.dnswl.org] -2.8 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [217.72.192.74 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list 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-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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;