aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrançois romieu <romieu@fr.zoreil.com>2014-04-02 19:13:43 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-03 14:36:29 -0400
commitd9bd6461681c78fbe18087c20b4bb47845cd5564 (patch)
treea71e38bfd17a386029d3f76c8b3ebf3ce133ef1c
parent56c8b193ea7052d191c344ef9196bb8d759e1abf (diff)
sxgbe: fix driver probe error path and driver removal leaks
sxgbe_drv_probe: mdio and priv->hw leaks sxgbe_drv_remove: clk and priv->hw leaks Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Acked-by: Byungho An <bh74.an@samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index a72688e8dc6c..27e8c824b204 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -2113,11 +2113,11 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
2113 /* allocate memory resources for Descriptor rings */ 2113 /* allocate memory resources for Descriptor rings */
2114 ret = txring_mem_alloc(priv); 2114 ret = txring_mem_alloc(priv);
2115 if (ret) 2115 if (ret)
2116 goto error_free_netdev; 2116 goto error_free_hw;
2117 2117
2118 ret = rxring_mem_alloc(priv); 2118 ret = rxring_mem_alloc(priv);
2119 if (ret) 2119 if (ret)
2120 goto error_free_netdev; 2120 goto error_free_hw;
2121 2121
2122 ndev->netdev_ops = &sxgbe_netdev_ops; 2122 ndev->netdev_ops = &sxgbe_netdev_ops;
2123 2123
@@ -2163,7 +2163,7 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
2163 if (IS_ERR(priv->sxgbe_clk)) { 2163 if (IS_ERR(priv->sxgbe_clk)) {
2164 netdev_warn(ndev, "%s: warning: cannot get CSR clock\n", 2164 netdev_warn(ndev, "%s: warning: cannot get CSR clock\n",
2165 __func__); 2165 __func__);
2166 goto error_clk_get; 2166 goto error_napi_del;
2167 } 2167 }
2168 2168
2169 /* If a specific clk_csr value is passed from the platform 2169 /* If a specific clk_csr value is passed from the platform
@@ -2182,24 +2182,27 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
2182 if (ret < 0) { 2182 if (ret < 0) {
2183 netdev_dbg(ndev, "%s: MDIO bus (id: %d) registration failed\n", 2183 netdev_dbg(ndev, "%s: MDIO bus (id: %d) registration failed\n",
2184 __func__, priv->plat->bus_id); 2184 __func__, priv->plat->bus_id);
2185 goto error_mdio_register; 2185 goto error_clk_put;
2186 } 2186 }
2187 2187
2188 ret = register_netdev(ndev); 2188 ret = register_netdev(ndev);
2189 if (ret) { 2189 if (ret) {
2190 pr_err("%s: ERROR %i registering the device\n", __func__, ret); 2190 pr_err("%s: ERROR %i registering the device\n", __func__, ret);
2191 goto error_netdev_register; 2191 goto error_mdio_unregister;
2192 } 2192 }
2193 2193
2194 sxgbe_check_ether_addr(priv); 2194 sxgbe_check_ether_addr(priv);
2195 2195
2196 return priv; 2196 return priv;
2197 2197
2198error_mdio_register: 2198error_mdio_unregister:
2199 sxgbe_mdio_unregister(ndev);
2200error_clk_put:
2199 clk_put(priv->sxgbe_clk); 2201 clk_put(priv->sxgbe_clk);
2200error_clk_get: 2202error_napi_del:
2201error_netdev_register:
2202 netif_napi_del(&priv->napi); 2203 netif_napi_del(&priv->napi);
2204error_free_hw:
2205 kfree(priv->hw);
2203error_free_netdev: 2206error_free_netdev:
2204 free_netdev(ndev); 2207 free_netdev(ndev);
2205 2208
@@ -2224,11 +2227,15 @@ int sxgbe_drv_remove(struct net_device *ndev)
2224 priv->hw->mac->enable_tx(priv->ioaddr, false); 2227 priv->hw->mac->enable_tx(priv->ioaddr, false);
2225 priv->hw->mac->enable_rx(priv->ioaddr, false); 2228 priv->hw->mac->enable_rx(priv->ioaddr, false);
2226 2229
2227 netif_napi_del(&priv->napi); 2230 unregister_netdev(ndev);
2228 2231
2229 sxgbe_mdio_unregister(ndev); 2232 sxgbe_mdio_unregister(ndev);
2230 2233
2231 unregister_netdev(ndev); 2234 clk_put(priv->sxgbe_clk);
2235
2236 netif_napi_del(&priv->napi);
2237
2238 kfree(priv->hw);
2232 2239
2233 free_netdev(ndev); 2240 free_netdev(ndev);
2234 2241