diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2015-11-16 06:33:17 -0500 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2015-12-03 01:58:23 -0500 |
commit | f6f31af81c77087c8884f5dc1ab91b029cd11842 (patch) | |
tree | 198a6c56602dd3ec9c8690e9eecfa1b2408ec2bd | |
parent | d0ca576af2120e23f2433041bf0865798e02c547 (diff) |
phy: rockchip-usb: 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>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r-- | drivers/phy/phy-rockchip-usb.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c index 91d6f342c565..62c43c435194 100644 --- a/drivers/phy/phy-rockchip-usb.c +++ b/drivers/phy/phy-rockchip-usb.c | |||
@@ -108,13 +108,16 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) | |||
108 | 108 | ||
109 | for_each_available_child_of_node(dev->of_node, child) { | 109 | for_each_available_child_of_node(dev->of_node, child) { |
110 | rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); | 110 | rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); |
111 | if (!rk_phy) | 111 | if (!rk_phy) { |
112 | return -ENOMEM; | 112 | err = -ENOMEM; |
113 | goto put_child; | ||
114 | } | ||
113 | 115 | ||
114 | if (of_property_read_u32(child, "reg", ®_offset)) { | 116 | if (of_property_read_u32(child, "reg", ®_offset)) { |
115 | dev_err(dev, "missing reg property in node %s\n", | 117 | dev_err(dev, "missing reg property in node %s\n", |
116 | child->name); | 118 | child->name); |
117 | return -EINVAL; | 119 | err = -EINVAL; |
120 | goto put_child; | ||
118 | } | 121 | } |
119 | 122 | ||
120 | rk_phy->reg_offset = reg_offset; | 123 | rk_phy->reg_offset = reg_offset; |
@@ -127,18 +130,22 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) | |||
127 | rk_phy->phy = devm_phy_create(dev, child, &ops); | 130 | rk_phy->phy = devm_phy_create(dev, child, &ops); |
128 | if (IS_ERR(rk_phy->phy)) { | 131 | if (IS_ERR(rk_phy->phy)) { |
129 | dev_err(dev, "failed to create PHY\n"); | 132 | dev_err(dev, "failed to create PHY\n"); |
130 | return PTR_ERR(rk_phy->phy); | 133 | err = PTR_ERR(rk_phy->phy); |
134 | goto put_child; | ||
131 | } | 135 | } |
132 | phy_set_drvdata(rk_phy->phy, rk_phy); | 136 | phy_set_drvdata(rk_phy->phy, rk_phy); |
133 | 137 | ||
134 | /* only power up usb phy when it use, so disable it when init*/ | 138 | /* only power up usb phy when it use, so disable it when init*/ |
135 | err = rockchip_usb_phy_power(rk_phy, 1); | 139 | err = rockchip_usb_phy_power(rk_phy, 1); |
136 | if (err) | 140 | if (err) |
137 | return err; | 141 | goto put_child; |
138 | } | 142 | } |
139 | 143 | ||
140 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | 144 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); |
141 | return PTR_ERR_OR_ZERO(phy_provider); | 145 | return PTR_ERR_OR_ZERO(phy_provider); |
146 | put_child: | ||
147 | of_node_put(child); | ||
148 | return err; | ||
142 | } | 149 | } |
143 | 150 | ||
144 | static const struct of_device_id rockchip_usb_phy_dt_ids[] = { | 151 | static const struct of_device_id rockchip_usb_phy_dt_ids[] = { |