Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp297644pxu; Wed, 2 Dec 2020 23:47:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwccZZcRwWlcH/v7kVLec4C/pG2IpQOqp7ZNA9KSn15R5odX0Fb2QuKpSZqnU503irWxfoM X-Received: by 2002:a05:6402:1d12:: with SMTP id dg18mr1744274edb.238.1606981679228; Wed, 02 Dec 2020 23:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606981679; cv=none; d=google.com; s=arc-20160816; b=s4gAI5hDLB8fdI7ehMO+s4Dp3JfbVeJ48MSxF0vasGkE95Lnb3oUTh4Tk5TrbdpUxu K4eSC0fDH6PzSjx7evzr0gt5S2H2xJlV+5tJCxswvwhfrAR/MWP2uM0TJx2denI+pGho HwXSA0MUN+Ha20fTc3KarWgI7u5BaGK7rZvndY7EHYhosCDS1gdyrBVPUawD8taiOJMP IaP/2uvbkVkTmU7io6AbssSjEce/puDup9+6uY10Des8PfFR4hCvenfabv8m+/gb9nv7 exQD70TgLQEOhoMQzQTG4+OBC5QlpLOgCwjJnQ/C6Z51w5u3ljeyaJFAJAXnVMj04DX3 5D2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=bf6jb1CBdKhveoWD8MLtxLt3N/jrbaGtwe4VRA9UZNg=; b=n4hC+AWH44Yw1vF2wtOcJRUd2Amdo2ohbEFfmouCt7RuIvsm7+PM5jUTp1CdH83EbS xHY9/LHCYR1NhoTe3zhPxHJkPU129loUcqPnoyq1o5iXmX79TM+f+hRpSXuYkPCU8jQQ +qeTW9Pa+8RKSaJ41MsvvHPvGsf+78tu1hm4ZDiXXfek6ZjjjSKGGKlaKwHJe3PnsaQE JL2fbt1+z8nTTnGy0A88uWqHZaGFvd2s+uQjMHmq81mRLFNMvgQLb5WNHmN845FXRE6S pKm/K7FEIboSTIgSMU5UYG9zRDB2hX+X9OmJypTNbhc3CuR6ageztug0bp+/GA6e9uiy XtvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si548008edx.51.2020.12.02.23.47.36; Wed, 02 Dec 2020 23:47:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387402AbgLCHqJ (ORCPT + 99 others); Thu, 3 Dec 2020 02:46:09 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:30312 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgLCHqI (ORCPT ); Thu, 3 Dec 2020 02:46:08 -0500 Received: from ironmsg07-lv.qualcomm.com (HELO ironmsg07-lv.qulacomm.com) ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 02 Dec 2020 23:45:27 -0800 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg07-lv.qulacomm.com with ESMTP/TLS/AES256-SHA; 02 Dec 2020 23:45:26 -0800 X-QCInternal: smtphost Received: from c-rojay-linux.qualcomm.com ([10.206.21.80]) by ironmsg01-blr.qualcomm.com with ESMTP; 03 Dec 2020 13:15:02 +0530 Received: by c-rojay-linux.qualcomm.com (Postfix, from userid 88981) id D45DF2819; Thu, 3 Dec 2020 13:15:01 +0530 (IST) From: Roja Rani Yarubandi To: broonie@kernel.org Cc: agross@kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org, dianders@chromium.org, linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, akashast@codeaurora.org, msavaliy@qti.qualcomm.com, Roja Rani Yarubandi Subject: [PATCH] spi: spi-geni-qcom: Fix NULL pointer access in geni_spi_isr Date: Thu, 3 Dec 2020 13:14:59 +0530 Message-Id: <20201203074459.13078-1-rojay@codeaurora.org> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Here, there is a chance of race condition occurrence which leads to NULL pointer dereference with struct spi_geni_master member 'cur_xfer' between setup_fifo_xfer() and handle_fifo_timeout() functions. Fix this race condition with guarding the 'cur_xfer' where it gets updated, with spin_lock_irq/spin_unlock_irq in setup_fifo_xfer() as we do in handle_fifo_timeout() function. Call trace: geni_spi_isr+0x114/0x34c __handle_irq_event_percpu+0xe0/0x23c handle_irq_event_percpu+0x34/0x8c handle_irq_event+0x48/0x94 handle_fasteoi_irq+0xd0/0x140 __handle_domain_irq+0x8c/0xcc gic_handle_irq+0x114/0x1dc el1_irq+0xcc/0x180 geni_spi a80000.spi: Failed to cancel/abort m_cmd dev_watchdog+0x348/0x354 call_timer_fn+0xc4/0x220 __run_timers+0x228/0x2d4 spi_master spi6: failed to transfer one message from queue run_timer_softirq+0x24/0x44 __do_softirq+0x16c/0x344 irq_exit+0xa8/0xac __handle_domain_irq+0x94/0xcc gic_handle_irq+0x114/0x1dc el1_irq+0xcc/0x180 cpuidle_enter_state+0xf8/0x204 cpuidle_enter+0x38/0x4c cros-ec-spi spi6.0: spi transfer failed: -110 ... Fixes: 2ee471a1e28e ("spi: spi-geni-qcom: Mo' betta locking") Signed-off-by: Roja Rani Yarubandi --- drivers/spi/spi-geni-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 25810a7eef10..e65d6676602b 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -457,7 +457,6 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, len = xfer->len / (mas->cur_bits_per_word / BITS_PER_BYTE + 1); len &= TRANS_LEN_MSK; - mas->cur_xfer = xfer; if (xfer->tx_buf) { m_cmd |= SPI_TX_ONLY; mas->tx_rem_bytes = xfer->len; @@ -475,6 +474,7 @@ static void setup_fifo_xfer(struct spi_transfer *xfer, * interrupt could come in at any time now. */ spin_lock_irq(&mas->lock); + mas->cur_xfer = xfer; geni_se_setup_m_cmd(se, m_cmd, FRAGMENTATION); /* -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation