Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2510348imm; Mon, 24 Sep 2018 05:41:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Bs9gn6cQl1PQqfIFgz+e0VIbmLLIIVpLtmlpzo0tWjs1tRbaSsY/hTBs50qKrpmk5HXQY X-Received: by 2002:a17:902:6ac5:: with SMTP id i5-v6mr10623738plt.232.1537792888689; Mon, 24 Sep 2018 05:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792888; cv=none; d=google.com; s=arc-20160816; b=gT3bcuHa6cV2cFc6stRP0olLXOV6G7SxI5RiIWj4SuPT18ashyk8OqiUs3MsIUwVOx gPRteJUaHhYUoKw5GMj9X3bMuTv1XuRt9Q7JK3BZTplL3IukKHbwuLcaF8E2q2z1Vmvw Hxhy22avZWcCVVAYCAwqeuCNWeGMgM75WIFHn4/iCcr3tMUYUcdiapjEqBkM8xRR5ydT Jt1ldtsciaHnIrSpvgqxVDSn1HolTcvYtQJGex4C4f3Gvr59Ptou/3AYG3V97YhT+JxU MSn8xWJZZ5G0VFA3KUQG6Vpct1IDXTQhqVJ1wmPLO7aAHfdoxvvSviwOJf565np0aIvP H36A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=aBYdttOimfCclrLSvP4lmpgf+xsQ/ctSgUcFxDbe0Dc=; b=SkqPT0CTLE0UHKfXlWtXroeF7vXMXO/oTHhPRxMQioeutZiZVLiEsmmtBOVqqtiR7f 8ry0s7NHWh8uUrJP3/Yj/4eFhbOFAhzgfYV/93GbLwTTfalXe4uqayGxnxSrjRkyGNdK +7lGmYjzbOdn9AL/86+4WPs4hWWdvA5UNrujIVaEPqjaPeqIprYahjQ+QE6+W3idDh6+ 9oQsUjgoiI1u+4dBxb/YuLEXktMcJ7VeWeRNGkSHtVUMgicthtFmOYbZMEwQOZQNPOsl 971YSwayyuFhtMwPfbaHtlRSK1T/ekIj571SlFD7JMbJfb2MOdm49UUBOPBs7fc+OyZH /+Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t79-v6si37203928pfa.170.2018.09.24.05.41.13; Mon, 24 Sep 2018 05:41:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388543AbeIXSmI (ORCPT + 99 others); Mon, 24 Sep 2018 14:42:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58928 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387876AbeIXSmH (ORCPT ); Mon, 24 Sep 2018 14:42:07 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ECA2F109B; Mon, 24 Sep 2018 12:40:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Belloni , Andy Shevchenko , Mark Brown , Sasha Levin Subject: [PATCH 4.18 153/235] spi: dw: fix possible race condition Date: Mon, 24 Sep 2018 13:52:19 +0200 Message-Id: <20180924113120.644318048@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexandre Belloni [ Upstream commit 66b19d762378785d1568b5650935205edfeb0503 ] It is possible to get an interrupt as soon as it is requested. dw_spi_irq does spi_controller_get_devdata(master) and expects it to be different than NULL. However, spi_controller_set_devdata() is called after request_irq(), resulting in the following crash: CPU 0 Unable to handle kernel paging request at virtual address 00000030, epc == 8058e09c, ra == 8018ff90 [...] Call Trace: [<8058e09c>] dw_spi_irq+0x8/0x64 [<8018ff90>] __handle_irq_event_percpu+0x70/0x1d4 [<80190128>] handle_irq_event_percpu+0x34/0x8c [<801901c4>] handle_irq_event+0x44/0x80 [<801951a8>] handle_level_irq+0xdc/0x194 [<8018f580>] generic_handle_irq+0x38/0x50 [<804c6924>] ocelot_irq_handler+0x104/0x1c0 Signed-off-by: Alexandre Belloni Reviewed-by: Andy Shevchenko Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-dw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -485,6 +485,8 @@ int dw_spi_add_host(struct device *dev, dws->dma_inited = 0; dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR); + spi_controller_set_devdata(master, dws); + ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev), master); if (ret < 0) { @@ -518,7 +520,6 @@ int dw_spi_add_host(struct device *dev, } } - spi_controller_set_devdata(master, dws); ret = devm_spi_register_controller(dev, master); if (ret) { dev_err(&master->dev, "problem registering spi master\n");