Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Varshini Rajendran" <varshini.rajendran@microchip.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 06/16] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65
Date: Mon, 27 Jul 2026 12:41:22 +0000	[thread overview]
Message-ID: <20260727124122.B394A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727122633.117435-7-varshini.rajendran@microchip.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The custom `DEFINE_FREE` implementation for `nvmem_cell_put` fails to check for error pointers, causing a kernel panic when `nvmem_cell_get` fails.
--

--- Patch [6]: [PATCH v4 06/16] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 ---
commit ded9daef979dc15e3d8816ca33992bea7aa02c01
Author: Varshini Rajendran <varshini.rajendran@microchip.com>

    iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65
    
    Add support for sama7d65 ADC. The differences are highlighted with the
    compatible. The calibration data layout is the main difference.

> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> index 63481ecb94f5e..a54691b38244f 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
[ ... ]
> @@ -768,6 +777,24 @@ static const struct at91_adc_platform sama7g5_platform = {
>  	.temp_calib_layout = &sama7g5_temp_calib,
>  };
>  
> +static const struct at91_adc_platform sama7d65_platform = {
> +	.layout = &sama7g5_layout,
> +	.adc_channels = &at91_sama7g5_adc_channels,
> +	.nr_channels = AT91_SAMA7G5_SINGLE_CHAN_CNT +
> +		       AT91_SAMA7G5_DIFF_CHAN_CNT +
> +		       AT91_SAMA7G5_TEMP_CHAN_CNT,
> +	.max_channels = ARRAY_SIZE(at91_sama7g5_adc_channels),
> +	.max_index = AT91_SAMA7G5_MAX_CHAN_IDX,
> +	.hw_trig_cnt = AT91_SAMA7G5_HW_TRIG_CNT,
> +	.osr_mask = GENMASK(18, 16),
> +	.oversampling_avail = { 1, 4, 16, 64, 256 },
> +	.oversampling_avail_no = 5,
> +	.chan_realbits = 16,
> +	.temp_sensor = true,

[Severity: High]
Could enabling the temperature sensor here expose this new platform to a panic
during probe?

When at91_adc_temp_sensor_init() is called for platforms with a temperature
sensor, it uses nvmem_cell_get() which returns an error pointer on failure:

	struct nvmem_cell *temp_calib __free(nvmem_cell_put) =
		nvmem_cell_get(dev, "temperature_calib");
	if (IS_ERR(temp_calib)) {
		if (PTR_ERR(temp_calib) != -ENOENT)
			dev_err(dev, "Failed to get temperature_calib cell!\n");
		return PTR_ERR(temp_calib);
	}

Because DEFINE_FREE for nvmem_cell_put is implemented with a simple check
instead of verifying for error pointers:

DEFINE_FREE(nvmem_cell_put, struct nvmem_cell *, if (_T) nvmem_cell_put(_T))

If nvmem_cell_get() fails, the ERR_PTR is evaluated as true by the cleanup
macro and passed directly to nvmem_cell_put(). This will immediately attempt
to dereference the error pointer, causing a kernel panic.

> +	.temp_chan = AT91_SAMA7G5_ADC_TEMP_CHANNEL,
> +	.temp_calib_layout = &sama7d65_temp_calib,
> +};
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727122633.117435-1-varshini.rajendran@microchip.com?part=6

  reply	other threads:[~2026-07-27 12:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 12:26 [PATCH v4 00/16] Add thermal management support for sama7d65 Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 01/16] dt-bindings: iio: adc: at91-sama5d2: document sama7d65 Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 02/16] iio: adc: at91-sama5d2_adc: use cleanup.h for NVMEM buffer Varshini Rajendran
2026-07-27 12:36   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 03/16] iio: adc: at91-sama5d2_adc: rework temp calibration layout handling Varshini Rajendran
2026-07-27 12:39   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 04/16] iio: adc: at91-sama5d2_adc: add condition to validate calibration data Varshini Rajendran
2026-07-27 12:42   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 05/16] iio: adc: at91-sama5d2_adc: remove unnecessary casts in of_device_id Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 06/16] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 Varshini Rajendran
2026-07-27 12:41   ` sashiko-bot [this message]
2026-07-27 12:26 ` [PATCH v4 07/16] dt-bindings: nvmem: microchip,sama7g5-otpc: add sama7d65 and dt node example Varshini Rajendran
2026-07-27 12:41   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 08/16] nvmem: microchip-otpc: nvmem: microchip-otpc: add tag-based packet lookup Varshini Rajendran
2026-07-27 12:44   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 09/16] nvmem: microchip-otpc: nvmem: add emulation mode and OTP access validation Varshini Rajendran
2026-07-27 12:39   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 10/16] ARM: dts: microchip: sama7d65: add cpu opps Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 11/16] ARM: dts: microchip: sama7d65: Add ADC node Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 12/16] ARM: dts: microchip: sama7d65_curiosity: Enable ADC, DVFS Varshini Rajendran
2026-07-27 12:26 ` [PATCH v4 13/16] ARM: dts: microchip: sama7d65: add otpc node Varshini Rajendran
2026-07-27 12:44   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 14/16] ARM: dts: microchip: sama7d65: add cells for temperature calibration Varshini Rajendran
2026-07-27 12:50   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 15/16] ARM: dts: microchip: sama7d65: add temperature sensor Varshini Rajendran
2026-07-27 12:45   ` sashiko-bot
2026-07-27 12:26 ` [PATCH v4 16/16] ARM: dts: microchip: sama7d65: add thermal zones node Varshini Rajendran

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=20260727124122.B394A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=varshini.rajendran@microchip.com \
    /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