From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: linux-phy@lists.infradead.org, neil.armstrong@linaro.org,
vkoul@kernel.org, olteanv@gmail.com
Subject: Re: [PATCH v13 01/12] spmi: Fix potential use-after-free by grabbing of_node reference
Date: Tue, 21 Jul 2026 09:49:52 +0000 [thread overview]
Message-ID: <20260721094952.7F6441F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260721093626.96264-2-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Improper resource release on error path in `spmi_controller_alloc()` leads to IDA corruption.
--
--- Patch [1]: [PATCH v13 01/12] spmi: Fix potential use-after-free by grabbing of_node reference ---
commit 7ae04c53ea07238f9983ba45fc72ac6070931cc9
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
spmi: Fix potential use-after-free by grabbing of_node reference
In of_spmi_register_devices(), a node is assigned to a newly created SPMI child
device during iteration. The refcount is dropped at every iteration, so a
use-after-free may occur when an overlay is dynamically unloaded. This commit
resolves the issue by increasing the of_node refcount when assigning the node
and releasing it in spmi_dev_release().
Closes: https://sashiko.dev/#/patchset/20260608100949.36309-1-angelogioacchino.delregno@collabora.com?part=2
> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
> index 57b7c0cb42407..f6d2f4bddfcd2 100644
> --- a/drivers/spmi/spmi.c
> +++ b/drivers/spmi/spmi.c
> @@ -24,6 +24,7 @@ static void spmi_dev_release(struct device *dev)
> {
> struct spmi_device *sdev = to_spmi_device(dev);
>
> + of_node_put(dev->of_node);
> kfree(sdev);
> }
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the resource
release paths in this file, I noticed a potential IDA corruption in
spmi_controller_alloc() during the error path.
If ida_alloc() fails under memory pressure:
drivers/spmi/spmi.c:spmi_controller_alloc() {
...
id = ida_alloc(&ctrl_ida, GFP_KERNEL);
if (id < 0) {
dev_err(parent,
"unable to allocate SPMI controller identifier.\n");
spmi_controller_put(ctrl);
return ERR_PTR(id);
}
...
}
It calls spmi_controller_put(ctrl), which eventually invokes spmi_ctrl_release():
drivers/spmi/spmi.c:spmi_ctrl_release() {
...
ida_free(&ctrl_ida, ctrl->nr);
kfree(ctrl);
}
Since the controller memory is zero-initialized and ctrl->nr hasn't
been set yet when ida_alloc() fails, ctrl->nr is implicitly 0.
Does this unconditionally free ID 0, inadvertently removing the identifier
for another active SPMI controller and leading to sysfs naming collisions
(spmi-0) on subsequent allocations?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721093626.96264-1-angelogioacchino.delregno@collabora.com?part=1
--
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-21 9:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 9:36 [PATCH v13 00/12] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 01/12] spmi: Fix potential use-after-free by grabbing of_node reference AngeloGioacchino Del Regno
2026-07-21 9:49 ` sashiko-bot [this message]
2026-07-21 9:36 ` [PATCH v13 02/12] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 03/12] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 04/12] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-07-21 9:49 ` sashiko-bot
2026-07-21 9:36 ` [PATCH v13 06/12] spmi: Add helper to get a parent SPMI device AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 07/12] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 08/12] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 09/12] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 10/12] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 11/12] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 12/12] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions 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=20260721094952.7F6441F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox