From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 11/23] i2c: pxa-pci: use platform_device_set_of_node()
Date: Sat, 30 May 2026 00:45:40 +0000 [thread overview]
Message-ID: <20260530004540.747721F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260521-pdev-fwnode-ref-v1-11-88c324a1b8d2@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] OF node reference leak when replacing direct assignment with platform_device_set_of_node().
--
commit 97e00c5939b668c9a126c1fc7447ee82d933bd92
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
i2c: pxa-pci: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
> index dbd542300f800..92a0647f08c69 100644
> --- a/drivers/i2c/busses/i2c-pxa-pci.c
> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
[ ... ]
> @@ -76,7 +76,8 @@ static struct platform_device *add_i2c_device(struct pci_dev *dev, int bar)
> goto out;
> }
> pdev->dev.parent = &dev->dev;
> - pdev->dev.of_node = child;
> +
> + platform_device_set_of_node(pdev, child);
[Severity: Medium]
Does this change result in an OF node reference leak?
Earlier in add_i2c_device(), the child node is acquired by breaking out of a
for_each_child_of_node loop, which holds a reference to the node:
for_each_child_of_node(dev->dev.of_node, child) {
...
break;
}
Previously, assigning pdev->dev.of_node = child implicitly transferred this
reference to the platform device, which would eventually be released during
device cleanup.
However, platform_device_set_of_node explicitly acquires an additional
reference via of_node_get:
drivers/base/platform.c:platform_device_set_of_node() {
...
pdev->dev.of_node = of_node_get(np);
...
}
Because the helper now manages its own reference, the original reference
held by the local child variable appears to be unconsumed. Should there
be an explicit of_node_put(child) called after platform_device_set_of_node
to prevent a leak?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260521-pdev-fwnode-ref-v1-0-88c324a1b8d2@oss.qualcomm.com?part=11
next prev parent reply other threads:[~2026-05-30 0:45 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 8:36 [PATCH 00/23] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 01/23] mfd: tps6586x: fix OF node refcount Bartosz Golaszewski
2026-05-27 15:36 ` (subset) " Lee Jones
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 02/23] net: mv643xx: " Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 03/23] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 04/23] pmdomain: imx: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 05/23] powerpc/powermac: " Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 06/23] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 07/23] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 08/23] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 09/23] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 10/23] powerpc/powermac: " Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 11/23] i2c: pxa-pci: " Bartosz Golaszewski
2026-05-21 9:13 ` Wolfram Sang
2026-05-30 0:45 ` sashiko-bot [this message]
2026-05-21 8:36 ` [PATCH 12/23] iommu/fsl: " Bartosz Golaszewski
2026-05-21 9:44 ` Robin Murphy
2026-05-21 8:36 ` [PATCH 13/23] net: bcmgenet: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 14/23] pmdomain: imx: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 15/23] mfd: tps6586: " Bartosz Golaszewski
2026-05-27 15:31 ` Lee Jones
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 16/23] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 17/23] net: mv643xx: " Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 18/23] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-21 8:36 ` [PATCH 19/23] platform/surface: gpe: " Bartosz Golaszewski
2026-05-28 11:21 ` Ilpo Järvinen
2026-05-21 8:36 ` [PATCH 20/23] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 21/23] usb: musb: " Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 22/23] reset: rzg2l: " Bartosz Golaszewski
2026-05-21 8:36 ` [PATCH 23/23] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
2026-05-30 0:45 ` sashiko-bot
2026-05-29 12:55 ` (subset) [PATCH 00/23] driver core: count references of the platform device's fwnode, not OF node Srinivas Kandagatla
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=20260530004540.747721F00899@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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