diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2015-11-16 06:33:15 -0500 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2015-12-03 01:58:23 -0500 |
commit | 2bb80ccda17b8ab2e4956ab0743c657b30631a3f (patch) | |
tree | 5190acf298b222a6aef15be9628c98a899e3c913 /drivers/phy | |
parent | 0b25ff8697d8074cee22269226c210605f97ec1b (diff) |
phy: mt65xx-usb3: 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 <Julia.Lawall@lip6.fr>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r-- | drivers/phy/phy-mt65xx-usb3.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index f30b28bd41fe..e427c3b788ff 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c | |||
@@ -415,7 +415,7 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) | |||
415 | struct resource *sif_res; | 415 | struct resource *sif_res; |
416 | struct mt65xx_u3phy *u3phy; | 416 | struct mt65xx_u3phy *u3phy; |
417 | struct resource res; | 417 | struct resource res; |
418 | int port; | 418 | int port, retval; |
419 | 419 | ||
420 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); | 420 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); |
421 | if (!u3phy) | 421 | if (!u3phy) |
@@ -447,31 +447,34 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) | |||
447 | for_each_child_of_node(np, child_np) { | 447 | for_each_child_of_node(np, child_np) { |
448 | struct mt65xx_phy_instance *instance; | 448 | struct mt65xx_phy_instance *instance; |
449 | struct phy *phy; | 449 | struct phy *phy; |
450 | int retval; | ||
451 | 450 | ||
452 | instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); | 451 | instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); |
453 | if (!instance) | 452 | if (!instance) { |
454 | return -ENOMEM; | 453 | retval = -ENOMEM; |
454 | goto put_child; | ||
455 | } | ||
455 | 456 | ||
456 | u3phy->phys[port] = instance; | 457 | u3phy->phys[port] = instance; |
457 | 458 | ||
458 | phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); | 459 | phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); |
459 | if (IS_ERR(phy)) { | 460 | if (IS_ERR(phy)) { |
460 | dev_err(dev, "failed to create phy\n"); | 461 | dev_err(dev, "failed to create phy\n"); |
461 | return PTR_ERR(phy); | 462 | retval = PTR_ERR(phy); |
463 | goto put_child; | ||
462 | } | 464 | } |
463 | 465 | ||
464 | retval = of_address_to_resource(child_np, 0, &res); | 466 | retval = of_address_to_resource(child_np, 0, &res); |
465 | if (retval) { | 467 | if (retval) { |
466 | dev_err(dev, "failed to get address resource(id-%d)\n", | 468 | dev_err(dev, "failed to get address resource(id-%d)\n", |
467 | port); | 469 | port); |
468 | return retval; | 470 | goto put_child; |
469 | } | 471 | } |
470 | 472 | ||
471 | instance->port_base = devm_ioremap_resource(&phy->dev, &res); | 473 | instance->port_base = devm_ioremap_resource(&phy->dev, &res); |
472 | if (IS_ERR(instance->port_base)) { | 474 | if (IS_ERR(instance->port_base)) { |
473 | dev_err(dev, "failed to remap phy regs\n"); | 475 | dev_err(dev, "failed to remap phy regs\n"); |
474 | return PTR_ERR(instance->port_base); | 476 | retval = PTR_ERR(instance->port_base); |
477 | goto put_child; | ||
475 | } | 478 | } |
476 | 479 | ||
477 | instance->phy = phy; | 480 | instance->phy = phy; |
@@ -483,6 +486,9 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) | |||
483 | provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); | 486 | provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); |
484 | 487 | ||
485 | return PTR_ERR_OR_ZERO(provider); | 488 | return PTR_ERR_OR_ZERO(provider); |
489 | put_child: | ||
490 | of_node_put(child_np); | ||
491 | return retval; | ||
486 | } | 492 | } |
487 | 493 | ||
488 | static const struct of_device_id mt65xx_u3phy_id_table[] = { | 494 | static const struct of_device_id mt65xx_u3phy_id_table[] = { |