From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: olteanv@gmail.com, neil.armstrong@linaro.org,
linux-phy@lists.infradead.org, vkoul@kernel.org
Subject: Re: [PATCH v10 10/11] iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add()
Date: Tue, 07 Jul 2026 09:03:13 +0000 [thread overview]
Message-ID: <20260707090314.2F8AD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707083730.33977-11-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Blind cast of `dev->parent` to `struct spmi_device` bypassing bus type validation can lead to a type confusion vulnerability and kernel panic.
--
--- Patch [10]: [PATCH v10 10/11] iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add() ---
commit e1eedb072014331c1e52822eb31e7a9aaeb3e848
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
iio: adc: qcom-spmi-iadc: Migrate to devm_spmi_subdevice_alloc_and_add()
This commit changes the driver to register a new SPMI sub-device and
initialize its own regmap rather than using the parent SPMI device's
regmap. This allows the regmap API to handle the base address directly.
> diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c
> --- a/drivers/iio/adc/qcom-spmi-iadc.c
> +++ b/drivers/iio/adc/qcom-spmi-iadc.c
[ ... ]
> @@ -502,18 +511,21 @@ 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)
> - return -ENODEV;
> + sparent = to_spmi_device(dev->parent);
> + sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
[Severity: High]
Could this blind cast to struct spmi_device cause a kernel panic if the
parent device isn't actually on the SPMI bus?
If a customized device tree or overlay instantiates this driver under a
non-SPMI parent node (for example, directly under simple-bus), dev->parent
will not be a valid spmi_device. When subdevice allocation accesses
sparent->ctrl, it will read memory overlapping with the parent's actual
structure, which can lead to an invalid pointer dereference.
The previous implementation safely handled this via dev_get_regmap(), but
this new cast bypasses bus type validation. Would it be better to use
spmi_find_device_by_of_node() here, similar to how it is used in other
drivers in this patch series, to ensure the device is safely retrieved?
> + if (IS_ERR(sub_sdev))
> + return PTR_ERR(sub_sdev);
>
> init_completion(&iadc->complete);
> mutex_init(&iadc->lock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707083730.33977-1-angelogioacchino.delregno@collabora.com?part=10
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-07 9:03 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 8:37 [PATCH v10 00/11] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:37 ` [PATCH v10 01/11] spmi: Fix potential use-after-free by grabbing of_node reference AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:53 ` sashiko-bot
2026-07-07 9:07 ` Andy Shevchenko
2026-07-07 9:07 ` Andy Shevchenko
2026-07-07 8:37 ` [PATCH v10 02/11] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:37 ` [PATCH v10 03/11] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:37 ` [PATCH v10 04/11] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:48 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 05/11] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:48 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 06/11] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:50 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 07/11] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:49 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 08/11] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:51 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 09/11] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:56 ` sashiko-bot
2026-07-07 8:37 ` [PATCH v10 10/11] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 9:03 ` sashiko-bot [this message]
2026-07-07 8:37 ` [PATCH v10 11/11] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
2026-07-07 8:37 ` AngeloGioacchino Del Regno
2026-07-07 8:55 ` sashiko-bot
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=20260707090314.2F8AD1F000E9@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.