All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 03/19] firmware: qcom: scm: Fix missing smp_load_acquire()
Date: Wed, 24 Jun 2026 19:24:18 +0000	[thread overview]
Message-ID: <20260624192418.92B761F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624190830.3131112-4-mukesh.ojha@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The waitqueue interrupt is requested and enabled before the global __scm pointer is published, leading to a potential NULL pointer dereference in the IRQ handler path.
--

commit 181d68fe28239c2e3b0bbf1762f175bcdf577648
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>

firmware: qcom: scm: Fix missing smp_load_acquire()

This commit fixes a potential ordering violation in
qcom_scm_set_download_mode() by using smp_load_acquire() to safely read
the __scm pointer published by qcom_scm_probe().

> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> index 9b06a69d3a6d7..c8a84836887f0 100644
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
[ ... ]
> @@ -2841,7 +2844,7 @@ static int qcom_scm_probe(struct platform_device *pdev)
>  	 * will cause the boot stages to enter download mode, unless
>  	 * disabled below by a clean shutdown/reboot.
>  	 */
> -	qcom_scm_set_download_mode(download_mode);
> +	qcom_scm_set_download_mode(scm, download_mode);

[Severity: High]
This is a pre-existing issue, but since we are looking at the initialization
ordering in qcom_scm_probe() in drivers/firmware/qcom/qcom_scm.c, could the
IRQ registration order cause a NULL pointer dereference?

Earlier in qcom_scm_probe(), the waitqueue interrupt is enabled before the
global __scm pointer is published:

	ret = devm_request_threaded_irq(scm->dev, irq, NULL, qcom_scm_irq_handler,
					IRQF_ONESHOT, "qcom-scm", scm);
	...
	smp_store_release(&__scm, scm);

If a pending hardware interrupt fires before __scm is published, the IRQ
handler will execute. The handler calls qcom_scm_waitq_wakeup(), which invokes
qcom_scm_get_completion().

Could qcom_scm_get_completion() crash here, since it ignores the valid scm
context passed via the IRQ data and unconditionally dereferences __scm?

drivers/firmware/qcom/qcom_scm.c:qcom_scm_get_completion() {
	if (WARN_ON_ONCE(wq_ctx >= __scm->wq_cnt))
		return ERR_PTR(-EINVAL);
	...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260624190830.3131112-1-mukesh.ojha@oss.qualcomm.com?part=3

  reply	other threads:[~2026-06-24 19:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 19:08 [PATCH v4 00/19] firmware: qcom: scm: Add minidump SRAM destination support Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 01/19] dt-bindings: firmware: qcom,scm: Add minidump SRAM property Mukesh Ojha
2026-06-24 19:19   ` sashiko-bot
2026-06-30 16:19     ` Rob Herring
2026-06-30 16:19   ` Rob Herring (Arm)
2026-06-24 19:08 ` [PATCH v4 02/19] dt-bindings: sram: qcom,imem: Add minidump-sram pattern property Mukesh Ojha
2026-06-30 16:20   ` Rob Herring (Arm)
2026-06-24 19:08 ` [PATCH v4 03/19] firmware: qcom: scm: Fix missing smp_load_acquire() Mukesh Ojha
2026-06-24 19:24   ` sashiko-bot [this message]
2026-06-24 19:08 ` [PATCH v4 04/19] firmware: qcom: scm: use dev_err_probe() for dload address failure Mukesh Ojha
2026-06-24 19:22   ` sashiko-bot
2026-06-25 11:29     ` Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 05/19] firmware: qcom: scm: Add minidump SRAM support Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 06/19] arm64: dts: qcom: kaanapali: Add minidump SRAM config to SCM node Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 07/19] arm64: dts: qcom: sm8450: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 08/19] arm64: dts: qcom: sa8775p: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 09/19] arm64: dts: qcom: qcs8300: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 10/19] arm64: dts: qcom: qdu1000: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 11/19] arm64: dts: qcom: sm8550: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 12/19] arm64: dts: qcom: sm8650: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 13/19] arm64: dts: qcom: sc7280: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 14/19] arm64: dts: qcom: sm8350: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 15/19] arm64: dts: qcom: sc7180: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 16/19] arm64: dts: qcom: sm6350: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 17/19] arm64: dts: qcom: sm6375: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 18/19] arm64: dts: qcom: qcs615: " Mukesh Ojha
2026-06-24 19:08 ` [PATCH v4 19/19] arm64: dts: qcom: sdm845: " Mukesh Ojha
2026-06-26 12:44   ` Konrad Dybcio
2026-07-13 15:06 ` (subset) [PATCH v4 00/19] firmware: qcom: scm: Add minidump SRAM destination support Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260624192418.92B761F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=mukesh.ojha@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.