aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2015-11-16 06:33:14 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2015-12-03 01:58:23 -0500
commit0b25ff8697d8074cee22269226c210605f97ec1b (patch)
tree119b635dd55f7606dbf723a9c9f4edfa930f5369 /drivers/phy
parent97dc5bf8d60938741e2f99242dff3684c29b6d90 (diff)
phy: brcmstb-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: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/phy-brcmstb-sata.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/phy/phy-brcmstb-sata.c b/drivers/phy/phy-brcmstb-sata.c
index 8a2cb16a1937..cd9dba820566 100644
--- a/drivers/phy/phy-brcmstb-sata.c
+++ b/drivers/phy/phy-brcmstb-sata.c
@@ -140,7 +140,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
140 struct brcm_sata_phy *priv; 140 struct brcm_sata_phy *priv;
141 struct resource *res; 141 struct resource *res;
142 struct phy_provider *provider; 142 struct phy_provider *provider;
143 int count = 0; 143 int ret, count = 0;
144 144
145 if (of_get_child_count(dn) == 0) 145 if (of_get_child_count(dn) == 0)
146 return -ENODEV; 146 return -ENODEV;
@@ -163,16 +163,19 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
163 if (of_property_read_u32(child, "reg", &id)) { 163 if (of_property_read_u32(child, "reg", &id)) {
164 dev_err(dev, "missing reg property in node %s\n", 164 dev_err(dev, "missing reg property in node %s\n",
165 child->name); 165 child->name);
166 return -EINVAL; 166 ret = -EINVAL;
167 goto put_child;
167 } 168 }
168 169
169 if (id >= MAX_PORTS) { 170 if (id >= MAX_PORTS) {
170 dev_err(dev, "invalid reg: %u\n", id); 171 dev_err(dev, "invalid reg: %u\n", id);
171 return -EINVAL; 172 ret = -EINVAL;
173 goto put_child;
172 } 174 }
173 if (priv->phys[id].phy) { 175 if (priv->phys[id].phy) {
174 dev_err(dev, "already registered port %u\n", id); 176 dev_err(dev, "already registered port %u\n", id);
175 return -EINVAL; 177 ret = -EINVAL;
178 goto put_child;
176 } 179 }
177 180
178 port = &priv->phys[id]; 181 port = &priv->phys[id];
@@ -182,7 +185,8 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
182 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); 185 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc");
183 if (IS_ERR(port->phy)) { 186 if (IS_ERR(port->phy)) {
184 dev_err(dev, "failed to create PHY\n"); 187 dev_err(dev, "failed to create PHY\n");
185 return PTR_ERR(port->phy); 188 ret = PTR_ERR(port->phy);
189 goto put_child;
186 } 190 }
187 191
188 phy_set_drvdata(port->phy, port); 192 phy_set_drvdata(port->phy, port);
@@ -198,6 +202,9 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
198 dev_info(dev, "registered %d port(s)\n", count); 202 dev_info(dev, "registered %d port(s)\n", count);
199 203
200 return 0; 204 return 0;
205put_child:
206 of_node_put(child);
207 return ret;
201} 208}
202 209
203static struct platform_driver brcm_sata_phy_driver = { 210static struct platform_driver brcm_sata_phy_driver = {