net: ethernet: ti: cpsw: fix secondary-emac probe error path
authorJohan Hovold <johan@kernel.org>
Thu, 17 Nov 2016 16:40:02 +0000 (17:40 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Nov 2016 18:48:53 +0000 (13:48 -0500)
Make sure to deregister the primary device in case the secondary emac
fails to probe.

kernel BUG at /home/johan/work/omicron/src/linux/net/core/dev.c:7743!
...
[<c05b3dec>] (free_netdev) from [<c04fe6c0>] (cpsw_probe+0x9cc/0xe50)
[<c04fe6c0>] (cpsw_probe) from [<c047b28c>] (platform_drv_probe+0x5c/0xc0)

Fixes: d9ba8f9e6298 ("driver: net: ethernet: cpsw: dual emac interface
implementation")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw.c

index c3b78bc..11b2dae 100644 (file)
@@ -2852,7 +2852,7 @@ static int cpsw_probe(struct platform_device *pdev)
                ret = cpsw_probe_dual_emac(priv);
                if (ret) {
                        cpsw_err(priv, probe, "error probe slave 2 emac interface\n");
-                       goto clean_ale_ret;
+                       goto clean_unregister_netdev_ret;
                }
        }
 
@@ -2860,6 +2860,8 @@ static int cpsw_probe(struct platform_device *pdev)
 
        return 0;
 
+clean_unregister_netdev_ret:
+       unregister_netdev(ndev);
 clean_ale_ret:
        cpsw_ale_destroy(cpsw->ale);
 clean_dma_ret: