[v2,net,stable,1/2] net: fec: restore dev_id in the cases of probe error

Message ID 1514947170-8887-2-git-send-email-fugang.duan@nxp.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • net: fec: clean up in the cases of probe error
Related show

Commit Message

Andy Duan Jan. 3, 2018, 2:39 a.m.
The static variable dev_id always plus one before netdev registerred.
It should restore the dev_id value in the cases of probe error.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Troy Kisky Jan. 3, 2018, 8:03 p.m. | #1
On 1/2/2018 6:39 PM, Fugang Duan wrote:
> The static variable dev_id always plus one before netdev registerred.
> It should restore the dev_id value in the cases of probe error.
> 
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index e17d10b..dae89bc 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3576,6 +3576,7 @@ static int fec_enet_get_irq_cnt(struct platform_device *pdev)
>  	of_node_put(phy_node);
>  failed_ioremap:
>  	free_netdev(ndev);
> +	dev_id--;


This should be before failed_ioremap.

>  
>  	return ret;
>  }
>

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index e17d10b..dae89bc 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3576,6 +3576,7 @@  static int fec_enet_get_irq_cnt(struct platform_device *pdev)
 	of_node_put(phy_node);
 failed_ioremap:
 	free_netdev(ndev);
+	dev_id--;
 
 	return ret;
 }