aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2015-11-16 06:33:16 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2015-12-03 01:58:23 -0500
commitd0ca576af2120e23f2433041bf0865798e02c547 (patch)
treed8e16abf88d12c300077963df2a5f9b6cd4385d4 /drivers/phy
parent2bb80ccda17b8ab2e4956ab0743c657b30631a3f (diff)
phy: berlin-sata: add missing of_node_put
for_each_available_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_available_child_of_node(root, child) { ... when != of_node_put(child) when != e = child ( return child; | * return ...; ) ... } // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-berlin-sata.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
index 77a2e054fdea..f84a33a1bdd9 100644
--- a/drivers/phy/phy-berlin-sata.c
+++ b/drivers/phy/phy-berlin-sata.c
@@ -195,7 +195,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
195 struct phy_provider *phy_provider; 195 struct phy_provider *phy_provider;
196 struct phy_berlin_priv *priv; 196 struct phy_berlin_priv *priv;
197 struct resource *res; 197 struct resource *res;
198 int i = 0; 198 int ret, i = 0;
199 u32 phy_id; 199 u32 phy_id;
200 200
201 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 201 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -237,22 +237,27 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
237 if (of_property_read_u32(child, "reg", &phy_id)) { 237 if (of_property_read_u32(child, "reg", &phy_id)) {
238 dev_err(dev, "missing reg property in node %s\n", 238 dev_err(dev, "missing reg property in node %s\n",
239 child->name); 239 child->name);
240 return -EINVAL; 240 ret = -EINVAL;
241 goto put_child;
241 } 242 }
242 243
243 if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) { 244 if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) {
244 dev_err(dev, "invalid reg in node %s\n", child->name); 245 dev_err(dev, "invalid reg in node %s\n", child->name);
245 return -EINVAL; 246 ret = -EINVAL;
247 goto put_child;
246 } 248 }
247 249
248 phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL); 250 phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL);
249 if (!phy_desc) 251 if (!phy_desc) {
250 return -ENOMEM; 252 ret = -ENOMEM;
253 goto put_child;
254 }
251 255
252 phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops); 256 phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops);
253 if (IS_ERR(phy)) { 257 if (IS_ERR(phy)) {
254 dev_err(dev, "failed to create PHY %d\n", phy_id); 258 dev_err(dev, "failed to create PHY %d\n", phy_id);
255 return PTR_ERR(phy); 259 ret = PTR_ERR(phy);
260 goto put_child;
256 } 261 }
257 262
258 phy_desc->phy = phy; 263 phy_desc->phy = phy;
@@ -269,6 +274,9 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
269 phy_provider = 274 phy_provider =
270 devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate); 275 devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate);
271 return PTR_ERR_OR_ZERO(phy_provider); 276 return PTR_ERR_OR_ZERO(phy_provider);
277put_child:
278 of_node_put(child);
279 return ret;
272} 280}
273 281
274static const struct of_device_id phy_berlin_sata_of_match[] = { 282static const struct of_device_id phy_berlin_sata_of_match[] = {