Skip to contentSkip to conversation

regulator: bq257xx: drop confusing configuration of_node

PATCH Superseded Johan Hovold 2 participants 7 messages Apr 8 – Jun 4 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: bq257xx: drop confusing configuration of_node

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.

---

This is a follow-up to the reused OF node imbalance series:

	https://lore.kernel.org/lkml/[email protected]/

to address a false-positive Sashiko report.

Johan

 drivers/regulator/bq257xx-regulator.c | 2 --
 1 file changed, 2 deletions(-)
drivers/regulator/bq257xx-regulator.c +0 -2
index 711dbe045383..86225566e10a 100644
@@ -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;
Signature · 1 line
2.52.0
maintainer
#1 lore raw
Quoted 3 lines · 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.

Copying in Chris.

Quoted 50 lines

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.

---

This is a follow-up to the reused OF node imbalance series:

	https://lore.kernel.org/lkml/[email protected]/

to address a false-positive Sashiko report.

Johan

 drivers/regulator/bq257xx-regulator.c | 2 --
 1 file changed, 2 deletions(-)
drivers/regulator/bq257xx-regulator.c +0 -2
index 711dbe045383..86225566e10a 100644
@@ -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;
Signature · 1 line
2.52.0
maintainer
#2 lore raw
Quoted 6 lines · Mark Brown
Quoted 3 lines · 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.

Copying in Chris.

Or not since hotmail is blocking kernel.org.

#3 lore raw
In reply to Johan Hovold
Quoted 17 lines · 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.

Quoted 7 lines

---

This is a follow-up to the reused OF node imbalance series:

	https://lore.kernel.org/lkml/[email protected]/

to address a false-positive Sashiko report.

Can this one be picked up now?

Johan

maintainer
#4 lore raw
Quoted 7 lines · Johan Hovold
Quoted 3 lines · 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.

Can this one be picked up now?

I have no idea what it was supposed to be applied against.

#5 lore raw
Quoted 10 lines · Mark Brown
Quoted 7 lines · Johan Hovold
Quoted 3 lines · 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.

Can this one be picked up now?

I have no idea what it was supposed to be applied against.

Since it does not fix a bug it can go in your regulator for-next branch.

Johan

maintainer
#6 lore raw
Quoted 5 lines · Johan Hovold
Quoted 1 line · Mark Brown

I have no idea what it was supposed to be applied against.

Since it does not fix a bug it can go in your regulator for-next branch.

No, I mean in the technical sense that I couldn't work out something that the git am operation worked on.