aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2014-08-07 15:58:46 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-07 19:02:58 -0400
commitc891c24c62b376e508a45eeeb9f37e1b94173126 (patch)
tree80e60ad7b5136a529507c97198afcd8c6ac78208
parent888c88b857cd974e65e6cacb0aece0dfdf9f27d1 (diff)
net: mvneta: Fix reference counting for phy_node
If there is a "phy" handle the probe function returns with holding a reference to that node. Make sure that in the fixed phy case there is also held a reference to yield a consistant state. Also add the corresponding of_node_put in the error path and the remove function. Fixes: 83895bedeee6 ("net: mvneta: add support for fixed links") Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP network unit") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index dadd9a5f6323..c9f1d1b7ef37 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2969,14 +2969,14 @@ static int mvneta_probe(struct platform_device *pdev)
2969 /* In the case of a fixed PHY, the DT node associated 2969 /* In the case of a fixed PHY, the DT node associated
2970 * to the PHY is the Ethernet MAC DT node. 2970 * to the PHY is the Ethernet MAC DT node.
2971 */ 2971 */
2972 phy_node = dn; 2972 phy_node = of_node_get(dn);
2973 } 2973 }
2974 2974
2975 phy_mode = of_get_phy_mode(dn); 2975 phy_mode = of_get_phy_mode(dn);
2976 if (phy_mode < 0) { 2976 if (phy_mode < 0) {
2977 dev_err(&pdev->dev, "incorrect phy-mode\n"); 2977 dev_err(&pdev->dev, "incorrect phy-mode\n");
2978 err = -EINVAL; 2978 err = -EINVAL;
2979 goto err_free_irq; 2979 goto err_put_phy_node;
2980 } 2980 }
2981 2981
2982 dev->tx_queue_len = MVNETA_MAX_TXD; 2982 dev->tx_queue_len = MVNETA_MAX_TXD;
@@ -2992,7 +2992,7 @@ static int mvneta_probe(struct platform_device *pdev)
2992 pp->clk = devm_clk_get(&pdev->dev, NULL); 2992 pp->clk = devm_clk_get(&pdev->dev, NULL);
2993 if (IS_ERR(pp->clk)) { 2993 if (IS_ERR(pp->clk)) {
2994 err = PTR_ERR(pp->clk); 2994 err = PTR_ERR(pp->clk);
2995 goto err_free_irq; 2995 goto err_put_phy_node;
2996 } 2996 }
2997 2997
2998 clk_prepare_enable(pp->clk); 2998 clk_prepare_enable(pp->clk);
@@ -3071,6 +3071,8 @@ err_free_stats:
3071 free_percpu(pp->stats); 3071 free_percpu(pp->stats);
3072err_clk: 3072err_clk:
3073 clk_disable_unprepare(pp->clk); 3073 clk_disable_unprepare(pp->clk);
3074err_put_phy_node:
3075 of_node_put(phy_node);
3074err_free_irq: 3076err_free_irq:
3075 irq_dispose_mapping(dev->irq); 3077 irq_dispose_mapping(dev->irq);
3076err_free_netdev: 3078err_free_netdev:
@@ -3088,6 +3090,7 @@ static int mvneta_remove(struct platform_device *pdev)
3088 clk_disable_unprepare(pp->clk); 3090 clk_disable_unprepare(pp->clk);
3089 free_percpu(pp->stats); 3091 free_percpu(pp->stats);
3090 irq_dispose_mapping(dev->irq); 3092 irq_dispose_mapping(dev->irq);
3093 of_node_put(pp->phy_node);
3091 free_netdev(dev); 3094 free_netdev(dev);
3092 3095
3093 return 0; 3096 return 0;