From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: olteanv@gmail.com, neil.armstrong@linaro.org, vkoul@kernel.org,
linux-phy@lists.infradead.org
Subject: Re: [PATCH v11 02/12] spmi: Remove redundant dev_name() print in spmi_device_add()
Date: Tue, 07 Jul 2026 10:30:55 +0000 [thread overview]
Message-ID: <20260707103056.2AD791F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260707101821.173319-3-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unbalanced of_node_put() in the error path of of_spmi_register_devices() leads to a double-put and use-after-free of the device node.
--
--- Patch [2]: [PATCH v11 02/12] spmi: Remove redundant dev_name() print in spmi_device_add() ---
commit f89306eb718cb1ef4d332962e10b5d601928293c
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
spmi: Remove redundant dev_name() print in spmi_device_add()
This commit removes redundant dev_name() prints from the debug and error
messages in spmi_device_add(). The dev_dbg() and dev_err() macros already
include the device name in their output, so explicitly printing it results
in duplication.
> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
> index 293e1adddcd71..9bee0cb3d9dc1 100644
> --- a/drivers/spmi/spmi.c
> +++ b/drivers/spmi/spmi.c
> @@ -71,12 +71,11 @@ int spmi_device_add(struct spmi_device *sdev)
>
> err = device_add(&sdev->dev);
> if (err < 0) {
> - dev_err(&sdev->dev, "Can't add %s, status %d\n",
> - dev_name(&sdev->dev), err);
> + dev_err(&sdev->dev, "Can't add device, status %d\n", err);
> goto err_device_add;
> }
[Severity: High]
Does this error path trigger a double-put of the device node in
of_spmi_register_devices()?
When spmi_device_add() fails, it returns an error to
of_spmi_register_devices(), which handles the failure like this:
drivers/spmi/spmi.c:of_spmi_register_devices() {
...
err = spmi_device_add(sdev);
if (err) {
dev_err(&sdev->dev,
"failure adding device. status %d\n", err);
of_node_put(node);
spmi_device_put(sdev);
}
...
}
Since a previous patch in this series updated spmi_dev_release() to also
call of_node_put(dev->of_node), wouldn't calling both of_node_put(node) and
spmi_device_put(sdev) drop the node reference twice?
This could consume the reference held by the
for_each_available_child_of_node() iterator, causing a use-after-free when
the iterator accesses node->sibling.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707101821.173319-1-angelogioacchino.delregno@collabora.com?part=2
--
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 10:30 UTC|newest]
Thread overview: 24+ 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 ` [PATCH v11 01/12] spmi: Fix potential use-after-free by grabbing of_node reference 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:30 ` sashiko-bot [this message]
2026-07-07 10:18 ` [PATCH v11 03/12] spmi: Print error status with %pe format 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: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: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 ` [PATCH v11 07/12] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() 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 11:02 ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 09/12] phy: qualcomm: eusb2-repeater: " 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 11:20 ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 11/12] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-07 11:24 ` sashiko-bot
2026-07-07 10:18 ` [PATCH v11 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=20260707103056.2AD791F00A3A@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