From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
olteanv@gmail.com, neil.armstrong@linaro.org
Subject: Re: [PATCH RESEND v8 05/10] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add()
Date: Tue, 12 May 2026 04:14:01 +0000 [thread overview]
Message-ID: <20260512041401.AF62CC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511100805.121432-6-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional cast of `dev->parent` to `struct spmi_device` without type checking causes a kernel panic on malformed device topology.
--
commit aa83048e771ba8a6fcbb09d6d04cc6bb0abc5859
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add()
This commit migrates the SDAM driver to register its own SPMI sub-device
and initialize a dedicated regmap. This allows the regmap API to handle
the base address offsets automatically instead of manually adding the base
address to every read/write call.
> diff --git a/drivers/nvmem/qcom-spmi-sdam.c b/drivers/nvmem/qcom-spmi-sdam.c
> --- a/drivers/nvmem/qcom-spmi-sdam.c
> +++ b/drivers/nvmem/qcom-spmi-sdam.c
[ ... ]
> @@ -110,8 +110,17 @@ static int sdam_write(void *priv, unsigned int offset, void *val,
>
> static int sdam_probe(struct platform_device *pdev)
> {
[ ... ]
> @@ -119,19 +128,23 @@ static int sdam_probe(struct platform_device *pdev)
> if (!sdam)
> return -ENOMEM;
>
> - sdam->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> - if (!sdam->regmap) {
> - dev_err(&pdev->dev, "Failed to get regmap handle\n");
> - return -ENXIO;
> - }
> + sparent = to_spmi_device(dev->parent);
> + sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
Could this lead to a kernel panic if the device is instantiated with a
malformed device tree?
If the device is placed at the root node where dev->parent is NULL, or under
a non-SPMI bus, to_spmi_device() will return an invalid spmi_device pointer
because it unconditionally casts dev->parent.
Passing this invalid pointer to devm_spmi_subdevice_alloc_and_add() would cause
a crash when it accesses the spmi_device fields.
The previous implementation safely handled this by calling dev_get_regmap(),
which returns NULL on an invalid parent and gracefully fails with -ENXIO.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511100805.121432-1-angelogioacchino.delregno@collabora.com?part=5
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-05-12 4:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 10:07 [PATCH RESEND v8 00/10] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-05-11 10:07 ` [PATCH RESEND v8 01/10] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-05-11 10:07 ` [PATCH RESEND v8 02/10] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-05-11 10:07 ` [PATCH RESEND v8 03/10] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-05-11 10:07 ` [PATCH RESEND v8 04/10] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-05-12 1:57 ` sashiko-bot
2026-05-11 10:08 ` [PATCH RESEND v8 05/10] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-05-12 4:14 ` sashiko-bot [this message]
2026-05-11 10:08 ` [PATCH RESEND v8 06/10] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-05-11 10:08 ` [PATCH RESEND v8 07/10] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-05-12 6:10 ` sashiko-bot
2026-05-11 10:08 ` [PATCH RESEND v8 08/10] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-05-11 10:08 ` [PATCH RESEND v8 09/10] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-05-11 10:08 ` [PATCH RESEND v8 10/10] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
2026-05-11 13:17 ` [PATCH RESEND v8 00/10] SPMI: Implement sub-devices and migrate drivers Jonathan Cameron
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=20260512041401.AF62CC2BCB0@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@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox