Skip to content

Commit 7fd7fa4

Browse files
JuliaLawallkishon
authored andcommitted
phy: miphy28lp: add missing of_node_put
for_each_child_of_node performs an of_node_get on each iteration, so a return from the middle of the loop requires an of_node_put. A simplified version of the semantic patch that finds this problem is as follows (http://coccinelle.lip6.fr): // <smpl> @@ expression root,e; local idexpression child; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child ( return child; | * return ...; ) ... } // </smpl> Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Kishon Vijay Abraham I <[email protected]>
1 parent f6f31af commit 7fd7fa4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/phy/phy-miphy28lp.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,27 +1226,30 @@ static int miphy28lp_probe(struct platform_device *pdev)
12261226

12271227
miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy),
12281228
GFP_KERNEL);
1229-
if (!miphy_phy)
1230-
return -ENOMEM;
1229+
if (!miphy_phy) {
1230+
ret = -ENOMEM;
1231+
goto put_child;
1232+
}
12311233

12321234
miphy_dev->phys[port] = miphy_phy;
12331235

12341236
phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops);
12351237
if (IS_ERR(phy)) {
12361238
dev_err(&pdev->dev, "failed to create PHY\n");
1237-
return PTR_ERR(phy);
1239+
ret = PTR_ERR(phy);
1240+
goto put_child;
12381241
}
12391242

12401243
miphy_dev->phys[port]->phy = phy;
12411244
miphy_dev->phys[port]->phydev = miphy_dev;
12421245

12431246
ret = miphy28lp_of_probe(child, miphy_phy);
12441247
if (ret)
1245-
return ret;
1248+
goto put_child;
12461249

12471250
ret = miphy28lp_probe_resets(child, miphy_dev->phys[port]);
12481251
if (ret)
1249-
return ret;
1252+
goto put_child;
12501253

12511254
phy_set_drvdata(phy, miphy_dev->phys[port]);
12521255
port++;
@@ -1255,6 +1258,9 @@ static int miphy28lp_probe(struct platform_device *pdev)
12551258

12561259
provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate);
12571260
return PTR_ERR_OR_ZERO(provider);
1261+
put_child:
1262+
of_node_put(child);
1263+
return ret;
12581264
}
12591265

12601266
static const struct of_device_id miphy28lp_of_match[] = {

0 commit comments

Comments
 (0)