* [PATCH] regulator: bq257xx: drop confusing configuration of_node
@ 2026-04-08 12:53 Johan Hovold
2026-04-08 13:18 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2026-04-08 12:53 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel, Johan Hovold
The driver reuses the OF node of the parent multi-function device but
still sets the of_node field of the regulator configuration to any prior
OF node.
Since the MFD child device does not have an OF node set until probe is
called, this field is set to NULL on first probe and to the reused OF
node if the driver is later rebound.
As the device_set_of_node_from_dev() helper drops a reference to any
prior OF node before taking a reference to the new one this can
apparently also confuse LLMs like Sashiko which flags it as a potential
use-after-free (which it is not).
Drop the confusing and redundant configuration of_node assignment.
Link: https://sashiko.dev/#/patchset/20260408073055.5183-1-johan%40kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
This is a follow-up to the reused OF node imbalance series:
https://lore.kernel.org/lkml/20260408073055.5183-1-johan@kernel.org/
to address a false-positive Sashiko report.
Johan
drivers/regulator/bq257xx-regulator.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/regulator/bq257xx-regulator.c b/drivers/regulator/bq257xx-regulator.c
index 711dbe045383..86225566e10a 100644
--- a/drivers/regulator/bq257xx-regulator.c
+++ b/drivers/regulator/bq257xx-regulator.c
@@ -139,7 +139,6 @@ static int bq257xx_regulator_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct bq257xx_device *bq = dev_get_drvdata(pdev->dev.parent);
struct bq257xx_reg_data *pdata;
- struct device_node *np = dev->of_node;
struct regulator_config cfg = {};
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
@@ -156,7 +155,6 @@ static int bq257xx_regulator_probe(struct platform_device *pdev)
cfg.dev = &pdev->dev;
cfg.driver_data = pdata;
- cfg.of_node = np;
cfg.regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!cfg.regmap)
return -ENODEV;
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: bq257xx: drop confusing configuration of_node
2026-04-08 12:53 [PATCH] regulator: bq257xx: drop confusing configuration of_node Johan Hovold
@ 2026-04-08 13:18 ` Mark Brown
2026-04-08 13:19 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-04-08 13:18 UTC (permalink / raw)
To: Johan Hovold; +Cc: Liam Girdwood, linux-kernel, Chris Morgan
[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]
On Wed, Apr 08, 2026 at 02:53:47PM +0200, Johan Hovold wrote:
> The driver reuses the OF node of the parent multi-function device but
> still sets the of_node field of the regulator configuration to any prior
> OF node.
Copying in Chris.
> Since the MFD child device does not have an OF node set until probe is
> called, this field is set to NULL on first probe and to the reused OF
> node if the driver is later rebound.
>
> As the device_set_of_node_from_dev() helper drops a reference to any
> prior OF node before taking a reference to the new one this can
> apparently also confuse LLMs like Sashiko which flags it as a potential
> use-after-free (which it is not).
>
> Drop the confusing and redundant configuration of_node assignment.
>
> Link: https://sashiko.dev/#/patchset/20260408073055.5183-1-johan%40kernel.org
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>
> This is a follow-up to the reused OF node imbalance series:
>
> https://lore.kernel.org/lkml/20260408073055.5183-1-johan@kernel.org/
>
> to address a false-positive Sashiko report.
>
> Johan
>
>
> drivers/regulator/bq257xx-regulator.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/regulator/bq257xx-regulator.c b/drivers/regulator/bq257xx-regulator.c
> index 711dbe045383..86225566e10a 100644
> --- a/drivers/regulator/bq257xx-regulator.c
> +++ b/drivers/regulator/bq257xx-regulator.c
> @@ -139,7 +139,6 @@ static int bq257xx_regulator_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct bq257xx_device *bq = dev_get_drvdata(pdev->dev.parent);
> struct bq257xx_reg_data *pdata;
> - struct device_node *np = dev->of_node;
> struct regulator_config cfg = {};
>
> device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
> @@ -156,7 +155,6 @@ static int bq257xx_regulator_probe(struct platform_device *pdev)
>
> cfg.dev = &pdev->dev;
> cfg.driver_data = pdata;
> - cfg.of_node = np;
> cfg.regmap = dev_get_regmap(pdev->dev.parent, NULL);
> if (!cfg.regmap)
> return -ENODEV;
> --
> 2.52.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: bq257xx: drop confusing configuration of_node
2026-04-08 13:18 ` Mark Brown
@ 2026-04-08 13:19 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-04-08 13:19 UTC (permalink / raw)
To: Johan Hovold; +Cc: Liam Girdwood, linux-kernel, Chris Morgan
[-- Attachment #1: Type: text/plain, Size: 366 bytes --]
On Wed, Apr 08, 2026 at 02:18:22PM +0100, Mark Brown wrote:
> On Wed, Apr 08, 2026 at 02:53:47PM +0200, Johan Hovold wrote:
> > The driver reuses the OF node of the parent multi-function device but
> > still sets the of_node field of the regulator configuration to any prior
> > OF node.
>
> Copying in Chris.
Or not since hotmail is blocking kernel.org.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-08 13:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 12:53 [PATCH] regulator: bq257xx: drop confusing configuration of_node Johan Hovold
2026-04-08 13:18 ` Mark Brown
2026-04-08 13:19 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox