From patchwork Mon Oct 17 22:13:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9380757 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 03B8F60487 for ; Mon, 17 Oct 2016 22:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D297928D00 for ; Mon, 17 Oct 2016 22:16:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C73A728D09; Mon, 17 Oct 2016 22:16:10 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82B4928D00 for ; Mon, 17 Oct 2016 22:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755806AbcJQWQD (ORCPT ); Mon, 17 Oct 2016 18:16:03 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:64383 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755736AbcJQWPv (ORCPT ); Mon, 17 Oct 2016 18:15:51 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MXTpy-1cQULR1C9W-00WXEL; Tue, 18 Oct 2016 00:15:11 +0200 From: Arnd Bergmann To: Mark Brown Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Arnd Bergmann , Heiner Kallweit , Nobuteru Hayashi , linux-spi@vger.kernel.org Subject: [PATCH 17/28] spi: fsl-espi: avoid processing uninitalized data on error Date: Tue, 18 Oct 2016 00:13:38 +0200 Message-Id: <20161017221355.1861551-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161017220342.1627073-1-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> X-Provags-ID: V03:K0:rokaZ/Po0+wYpl0FlSzVGhpiU9cVBLni5ELlWlBcoK+jO7tORyv 9UK9BDA12Pli5lxSaj7PEcDGMXSwiMb/ni4LN2P8Vu3M1z23UTkH+I/YE4zOWIYb1uylRJo IN3geDXTmpcDbP9TlhwROTG6Pg5xKr51pml8H9GY7H8eDlwwtCyeb9yV6X6/ZRS09spTPtq WJqdOLPNFpzSeZ7ZlzBWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:9Q3iAq08sE4=:6ZBrmL+iCVwQ+GFq1RrxNI yGScp8mZZVAKhMfW2/MrjzSpLAnuqwoYuDFbFbyagnypQD5z5bbBHInNs9mx8ha5PzaMxdy+z 7lbfWE/wX6lbHoaCxpv3aRBOSqdlDLqo49/PK6yIUgM6k/AHkLu/7q2RWokC2mbVVzRJAXw7Q 7s5GuEXIjFJ6CuZn6SHuV1uZUfo3Q+NTt+alj/hpskVVHa1hYluti/rmjH7qgij8CK5dGN8/9 lakUrf0kMoNACuxEKfK3GCGa2EPARbqNAUR9EM0gitHVXCDbSBH4BeJbk20ITPMIEspUzX0RT aOUGeMVoqZPMdKky7FMI8VJ/+K+9L3fwQp+QjbFS1JYjTiUeYCrS4sSP2jsHpVGq6jL0Bn34H TsvkX68Xwxf5g1AJhdVM/bn5qBz/asb6tdk1GZBgMRxz2bAFsTbgHpC/2m2tiYIB5lOMEQu6C W9nKNkWnxK1lsgaXlF3RgguKy25yqOffL3D2y8kw1/m7NGfYEvH36sfy7s7uZ15O4OeQf8wjJ Tx/0bNSYQZLp3R4viIb7Ad3cbtbNchSRjxyhOOfjjiCJv2GpgEWutsezGDrdXFdb4P4laF26Z fdHnLTgp3yp0hyu3RgbGz7a/z8E3xLEHZ6yWyvw1TxzjrNIzThxRYZN2TTTOYx/jMHyckYKk/ 0mf5SjJlzLGFsYJf5oXNRj+H0Ad6bKt+BVMYUeAhAakn6luek2Q82iXsDHkR2TVSX9M4= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we get a spurious interrupt in fsl_espi_irq, we end up processing four uninitalized bytes of data, as shown in this warning message: drivers/spi/spi-fsl-espi.c: In function 'fsl_espi_irq': drivers/spi/spi-fsl-espi.c:462:4: warning: 'rx_data' may be used uninitialized in this function [-Wmaybe-uninitialized] This adds another check so we skip the data in this case. Signed-off-by: Arnd Bergmann --- drivers/spi/spi-fsl-espi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 7451585..2c175b9 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -458,7 +458,7 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) mspi->len -= rx_nr_bytes; - if (mspi->rx) + if (rx_nr_bytes && mspi->rx) mspi->get_rx(rx_data, mspi); }