aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/mdio-mux.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/mdio-mux.c')
-rw-r--r--drivers/net/phy/mdio-mux.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 963838d4fac1..599ce24c514f 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -122,10 +122,9 @@ int mdio_mux_init(struct device *dev,
122 pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL); 122 pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
123 if (pb == NULL) { 123 if (pb == NULL) {
124 ret_val = -ENOMEM; 124 ret_val = -ENOMEM;
125 goto err_parent_bus; 125 goto err_pb_kz;
126 } 126 }
127 127
128
129 pb->switch_data = data; 128 pb->switch_data = data;
130 pb->switch_fn = switch_fn; 129 pb->switch_fn = switch_fn;
131 pb->current_child = -1; 130 pb->current_child = -1;
@@ -154,6 +153,7 @@ int mdio_mux_init(struct device *dev,
154 cb->mii_bus = mdiobus_alloc(); 153 cb->mii_bus = mdiobus_alloc();
155 if (!cb->mii_bus) { 154 if (!cb->mii_bus) {
156 ret_val = -ENOMEM; 155 ret_val = -ENOMEM;
156 devm_kfree(dev, cb);
157 of_node_put(child_bus_node); 157 of_node_put(child_bus_node);
158 break; 158 break;
159 } 159 }
@@ -170,7 +170,6 @@ int mdio_mux_init(struct device *dev,
170 mdiobus_free(cb->mii_bus); 170 mdiobus_free(cb->mii_bus);
171 devm_kfree(dev, cb); 171 devm_kfree(dev, cb);
172 } else { 172 } else {
173 of_node_get(child_bus_node);
174 cb->next = pb->children; 173 cb->next = pb->children;
175 pb->children = cb; 174 pb->children = cb;
176 } 175 }
@@ -181,9 +180,11 @@ int mdio_mux_init(struct device *dev,
181 return 0; 180 return 0;
182 } 181 }
183 182
183 devm_kfree(dev, pb);
184err_pb_kz:
184 /* balance the reference of_mdio_find_bus() took */ 185 /* balance the reference of_mdio_find_bus() took */
185 put_device(&pb->mii_bus->dev); 186 if (!mux_bus)
186 187 put_device(&parent_bus->dev);
187err_parent_bus: 188err_parent_bus:
188 of_node_put(parent_bus_node); 189 of_node_put(parent_bus_node);
189 return ret_val; 190 return ret_val;