All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: olteanv@gmail.com, linux-phy@lists.infradead.org,
	neil.armstrong@linaro.org, vkoul@kernel.org
Subject: Re: [PATCH v11 11/12] iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add()
Date: Tue, 07 Jul 2026 11:24:45 +0000	[thread overview]
Message-ID: <20260707112446.4B1401F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707101821.173319-12-angelogioacchino.delregno@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional probe failure due to an incorrect argument passed to `spmi_get_parent_spmi_device()`.
--

--- Patch [11]: [PATCH v11 11/12] iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add() ---
commit a65138c323454925e722f4d8782149a45b65f227
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

    iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add()

This commit migrates the Qualcomm SPMI IADC driver to use
devm_spmi_subdevice_alloc_and_add() to register an SPMI sub-device.
Instead of treating the parent PMIC as a syscon, it initializes its own
regmap with the sub-device's specific base address, allowing the regmap
API to handle register base offsets.

> diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c
> index 0ec3a0c4b1de0..71049cdc27653 100644
> --- a/drivers/iio/adc/qcom-spmi-iadc.c
> +++ b/drivers/iio/adc/qcom-spmi-iadc.c

[ ... ]

> @@ -502,18 +508,24 @@ static int iadc_probe(struct platform_device *pdev)
>  	iadc = iio_priv(indio_dev);
>  	iadc->dev = dev;
>  
> -	iadc->regmap = dev_get_regmap(dev->parent, NULL);
> -	if (!iadc->regmap)
> +	sparent = spmi_get_parent_spmi_device(dev->parent);

[Severity: High]
Does this code inadvertently pass the wrong argument to
spmi_get_parent_spmi_device()?

Looking at the implementation of spmi_get_parent_spmi_device():

struct spmi_device *spmi_get_parent_spmi_device(struct device *dev)
{
	struct device *parent;

	if (dev && dev->parent) {
		parent = dev->parent;

		if (parent->type == &spmi_dev_type)
			return to_spmi_device(parent);
	}
	return NULL;
}

If we pass dev->parent, the helper will evaluate the grandparent's type
instead of the parent's. Since the grandparent is the SPMI controller
(&spmi_ctrl_type), this condition will fail, causing sparent to be NULL
and leading to an unconditional -ENODEV probe failure.

Should this be passing dev instead?

> +	if (!sparent)
>  		return -ENODEV;
>  
> +	sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
> +	if (IS_ERR(sub_sdev))
> +		return PTR_ERR(sub_sdev);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707101821.173319-1-angelogioacchino.delregno@collabora.com?part=11

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-07-07 11:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 10:18 [PATCH v11 00/12] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-07-07 10:18 ` AngeloGioacchino Del Regno
2026-07-07 10:18 ` [PATCH v11 01/12] spmi: Fix potential use-after-free by grabbing of_node reference AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:28   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 02/12] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:30   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 03/12] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:38   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 04/12] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:39   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:48   ` sashiko-bot
2026-07-07 11:13     ` AngeloGioacchino Del Regno
2026-07-07 10:18 ` [PATCH v11 06/12] spmi: Add helper to get a parent SPMI device AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 10:18 ` [PATCH v11 07/12] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 11:08   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 08/12] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 11:02   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 09/12] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 11:12   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 10/12] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 11:20   ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 11/12] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno
2026-07-07 11:24   ` sashiko-bot [this message]
2026-07-07 10:18 ` [PATCH v11 12/12] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
2026-07-07 10:18   ` AngeloGioacchino Del Regno

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=20260707112446.4B1401F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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.