Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: stmmac: fix notifier registration

We cannot register the same netdev notifier multiple times when probing
stmmac devices. Register the notifier only once in module init, and also
make debugfs creation/deletion safe against simultaneous notifier call.

Fixes: 481a7d154cbb ("stmmac: debugfs entry name is not be changed when udev rename device name.")
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Aaro Koskinen and committed by
David S. Miller
474a31e1 c87a9d6f

+8 -5
+8 -5
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 4405 4405 { 4406 4406 struct stmmac_priv *priv = netdev_priv(dev); 4407 4407 4408 + rtnl_lock(); 4409 + 4408 4410 /* Create per netdev entries */ 4409 4411 priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir); 4410 4412 ··· 4418 4416 debugfs_create_file("dma_cap", 0444, priv->dbgfs_dir, dev, 4419 4417 &stmmac_dma_cap_fops); 4420 4418 4421 - register_netdevice_notifier(&stmmac_notifier); 4419 + rtnl_unlock(); 4422 4420 } 4423 4421 4424 4422 static void stmmac_exit_fs(struct net_device *dev) 4425 4423 { 4426 4424 struct stmmac_priv *priv = netdev_priv(dev); 4427 4425 4428 - unregister_netdevice_notifier(&stmmac_notifier); 4429 4426 debugfs_remove_recursive(priv->dbgfs_dir); 4430 4427 } 4431 4428 #endif /* CONFIG_DEBUG_FS */ ··· 4941 4940 4942 4941 netdev_info(priv->dev, "%s: removing driver", __func__); 4943 4942 4944 - #ifdef CONFIG_DEBUG_FS 4945 - stmmac_exit_fs(ndev); 4946 - #endif 4947 4943 stmmac_stop_all_dma(priv); 4948 4944 4949 4945 stmmac_mac_set(priv, priv->ioaddr, false); 4950 4946 netif_carrier_off(ndev); 4951 4947 unregister_netdev(ndev); 4948 + #ifdef CONFIG_DEBUG_FS 4949 + stmmac_exit_fs(ndev); 4950 + #endif 4952 4951 phylink_destroy(priv->phylink); 4953 4952 if (priv->plat->stmmac_rst) 4954 4953 reset_control_assert(priv->plat->stmmac_rst); ··· 5167 5166 /* Create debugfs main directory if it doesn't exist yet */ 5168 5167 if (!stmmac_fs_dir) 5169 5168 stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL); 5169 + register_netdevice_notifier(&stmmac_notifier); 5170 5170 #endif 5171 5171 5172 5172 return 0; ··· 5176 5174 static void __exit stmmac_exit(void) 5177 5175 { 5178 5176 #ifdef CONFIG_DEBUG_FS 5177 + unregister_netdevice_notifier(&stmmac_notifier); 5179 5178 debugfs_remove_recursive(stmmac_fs_dir); 5180 5179 #endif 5181 5180 }