]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: mdio: unexport __init-annotated mdio_bus_init()
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 6 Jun 2022 04:53:53 +0000 (13:53 +0900)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:52:59 +0000 (10:52 +0200)
BugLink: https://bugs.launchpad.net/bugs/1982968
[ Upstream commit 35b42dce619701f1300fb8498dae82c9bb1f0263 ]

EXPORT_SYMBOL and __init is a bad combination because the .init.text
section is freed up after the initialization. Hence, modules cannot
use symbols annotated __init. The access to a freed symbol may end up
with kernel panic.

modpost used to detect it, but it has been broken for a decade.

Recently, I fixed modpost so it started to warn it again, then this
showed up in linux-next builds.

There are two ways to fix it:

  - Remove __init
  - Remove EXPORT_SYMBOL

I chose the latter for this case because the only in-tree call-site,
drivers/net/phy/phy_device.c is never compiled as modular.
(CONFIG_PHYLIB is boolean)

Fixes: 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/phy/mdio_bus.c

index 8dc6e6269c65e0ec6e13c553a1772c00fa80347c..2c0216fe58def2ce966d45263894aa6991c4491c 100644 (file)
@@ -1011,7 +1011,6 @@ int __init mdio_bus_init(void)
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(mdio_bus_init);
 
 #if IS_ENABLED(CONFIG_PHYLIB)
 void mdio_bus_exit(void)