From patchwork Thu Oct 27 05:55:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9398895 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 0DCC560234 for ; Thu, 27 Oct 2016 05:55:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA0FF2A021 for ; Thu, 27 Oct 2016 05:55:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD9332A023; Thu, 27 Oct 2016 05:55:46 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 391622A021 for ; Thu, 27 Oct 2016 05:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933347AbcJ0Fzp (ORCPT ); Thu, 27 Oct 2016 01:55:45 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34155 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933288AbcJ0Fzp (ORCPT ); Thu, 27 Oct 2016 01:55:45 -0400 Received: by mail-wm0-f66.google.com with SMTP id y138so900195wme.1 for ; Wed, 26 Oct 2016 22:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=1uK9xcHFecPU7clVm4M9ioCEnuEI4C9qh9oYNaMSC04=; b=r3h2RQLvMdWZa76RpNtyFRePq6uti/YozQhoDe+VsalAftWdvZhQFXONyN2vIacLwP 8IAaDmvHL1S79mAanZjQgGsfo8FsuFrGO7BIOhtzldTsxPs60RWbOgTNGHDo3tTgBmbg YUrogcDfDy6eYHo/GbLe3kFzMl7ocPf2rbA1s74oYZo6JWUiPoBkfmVSRxYZeo3kZqTf EjHkOluzf72OefpLGw/dzrr1JnQrocIaV5WG2W64+40zu5JT4QyVVu1gZVfXhu1nNGb0 jeXyBEZ17FG767pP6rfyV1IWMRLErxdsM+O6OaexnEoP38AA2Yp7pjqi7U8YWPxBOzTl 7i4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=1uK9xcHFecPU7clVm4M9ioCEnuEI4C9qh9oYNaMSC04=; b=SCUxEhJe/KBmO/NJxUYjcdewol2kLwQGNgvx2kLauKoJE80DDGosd6Vhd529zGwsQL jRoabeTpkwP/kTlERwv+nkDB92LY1UcspXg0AJ/kCkspYfEWWkwm1FhMPUG/VlIIKVVT 4aXJCK4h9WPqiwuXbuvczDz3hXvWuV7OjFV512A5eqaQ1BE5W84KHFC/hG08d+lPDIRw f277lQdn9RSpzYou4zGeettuW4dCz1wRFTydcEhcDyr4pnmWzVPlbhp3xgGezLh0JUT8 dsiAENVaBF6DLv/zPbwKJ/bF4ZxCQubM4WgIGLCmqj5p5gsqLD6+yfXYfmREir0fRxRq r/LA== X-Gm-Message-State: ABUngvfy7T7L4p5TMJxpPswyLLrscU/lx8klWk4+X0kKye5CelHdkOfxEHI9EZ8xPg8QUA== X-Received: by 10.28.46.202 with SMTP id u193mr5650581wmu.53.1477547743325; Wed, 26 Oct 2016 22:55:43 -0700 (PDT) Received: from ?IPv6:2003:62:5f6e:ba00:8069:e868:4f37:eb08? (p200300625F6EBA008069E8684F37EB08.dip0.t-ipconnect.de. [2003:62:5f6e:ba00:8069:e868:4f37:eb08]) by smtp.googlemail.com with ESMTPSA id m5sm1212354wmd.17.2016.10.26.22.55.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Oct 2016 22:55:42 -0700 (PDT) To: Mark Brown Cc: Arnd Bergmann , "linux-spi@vger.kernel.org" From: Heiner Kallweit Subject: [PATCH] spi: fsl-espi: avoid processing uninitalized data on error Message-ID: Date: Thu, 27 Oct 2016 07:55:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 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. A functionally identical patch was submitted for stable already, however due to a merge conflict a separate patch is needed for next. Fixes: 6319a68011b8 ("spi/fsl-espi: avoid infinite loops on fsl_espi_cpu_irq()") Signed-off-by: Arnd Bergmann Signed-off-by: Heiner Kallweit --- 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 eea5123..4e8a99d 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -455,7 +455,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) { *(u32 *)mspi->rx = rx_data; mspi->rx += 4; }