Devicetree
 help / color / mirror / Atom feed
From: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/4] arm64: dts: qcom: monaco-pmics: Add ADC support for PMM8620AU
Date: Tue, 7 Jul 2026 19:00:48 +0530	[thread overview]
Message-ID: <5face958-656b-4287-adf6-6dbeeaddf4c8@oss.qualcomm.com> (raw)
In-Reply-To: <20260614081546.585941F000E9@smtp.kernel.org>

On 6/14/2026 1:45 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] The ADC interrupt handler `adc5_gen3_isr()` may dereference a NULL pointer `adc->handler` if an interrupt fires before the thermal auxiliary driver has registered its event notifier.
> --
> 
> commit 2afa9a558734cf9fc6ad1120da9026df8390137c
> Author: Ayyagari Ushasreevalli <aushasre@qti.qualcomm.com>
> 
> arm64: dts: qcom: monaco-pmics: Add ADC support for PMM8620AU
>     
> This commit adds ADC nodes for PMM8620AU PMIC instances on the Monaco
> platform. It exposes the DIE_TEMP and VPH_PWR channels.
> 
>> diff --git a/arch/arm64/boot/dts/qcom/monaco-pmics.dtsi b/arch/arm64/boot/dts/qcom/monaco-pmics.dtsi
>> index e990d7367719b..232bcb942b54c 100644
>> --- a/arch/arm64/boot/dts/qcom/monaco-pmics.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/monaco-pmics.dtsi
> [ ... ]
>> @@ -20,6 +21,27 @@ pmm8620au_0_rtc: rtc@6100 {
>>  			interrupts = <0x0 0x62 0x1 IRQ_TYPE_EDGE_RISING>;
>>  		};
>>  
>> +		pmm8620au_0_adc: adc@8000 {
>> +			compatible = "qcom,spmi-adc5-gen3";
>> +			reg = <0x8000>;
>> +			#address-cells = <1>;
>> +			#size-cells = <0>;
>> +			interrupts = <0x0 0x80 0x1 IRQ_TYPE_EDGE_RISING>;
> 
> [Severity: High]
> This is a pre-existing issue, but by enabling the qcom,spmi-adc5-gen3
> interrupts here, does this expose a NULL pointer dereference in the
> ADC driver's interrupt handler?
> 
> In drivers/iio/adc/qcom-spmi-adc5-gen3.c:adc5_gen3_isr(), the handler
> checks the device driver state rather than the function pointer:
> 
> 		adev = adc->tm_aux;
> 		if (!adev || !adev->dev.driver) {
> 			dev_err(dev, "adc_tm auxiliary device not initialized\n");
> 			return IRQ_HANDLED;
> 		}
> 
> 		adc->handler(adev);
> 

At present, the auxiliary ADC_TM driver is not present in the code.

The above code block lies within this if check:

    if (tm_status[0] || tm_status[1])

This requires some channels to be configured for TM measurements
and a threshold violation to have happened, which is not possible
if the driver is absent.

Even if the interrupt is somehow triggered for TM violation, since
the driver does not exist, adev->dev.driver will always be NULL,
so execution will enter the error condition and return without reaching
adc->handler.

In the latest patch series for adding the auxiliary ADC_TM driver,
https://lore.kernel.org/all/20260705-gen3_adc_tm-v3-0-ac62f387dbce@oss.qualcomm.com/,
the above logic is removed from adc5_gen3_isr(), so this issue
won't happen.

Thanks,
Jishnu

> If an interrupt fires after the driver core sets adev->dev.driver but
> before the thermal driver calls adc5_gen3_register_tm_event_notifier()
> to set adc->handler, will this result in a kernel panic by dereferencing
> a NULL adc->handler?
> 


  reply	other threads:[~2026-07-07 13:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-14  8:05 [PATCH v2 0/4] Add ADC support for lemans, monaco and hamoa Jishnu Prakash
2026-06-14  8:05 ` [PATCH v2 1/4] arm64: dts: qcom: Add header file for ADC5 Gen3 channel macros Jishnu Prakash
2026-06-14  8:12   ` sashiko-bot
2026-07-07 13:30     ` Jishnu Prakash
2026-06-14  8:05 ` [PATCH v2 2/4] arm64: dts: qcom: lemans-pmics: Add ADC support for PMM8654au Jishnu Prakash
2026-06-30 12:04   ` Konrad Dybcio
2026-07-07 13:31     ` Jishnu Prakash
2026-06-14  8:05 ` [PATCH v2 3/4] arm64: dts: qcom: monaco-pmics: Add ADC support for PMM8620AU Jishnu Prakash
2026-06-14  8:15   ` sashiko-bot
2026-07-07 13:30     ` Jishnu Prakash [this message]
2026-06-30 12:02   ` Konrad Dybcio
2026-06-14  8:05 ` [PATCH v2 4/4] arm64: dts: qcom: hamoa-pmics: Add ADC support Jishnu Prakash
2026-06-14  8:17   ` sashiko-bot
2026-07-07 13:31     ` Jishnu Prakash
2026-06-30 12:01   ` Konrad Dybcio
2026-07-07 13:31     ` Jishnu Prakash
2026-07-11 19:41   ` 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=5face958-656b-4287-adf6-6dbeeaddf4c8@oss.qualcomm.com \
    --to=jishnu.prakash@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox