[PATCH] net: mdio: octeon: use %p for bus id

Chen Jung Ku posted 1 patch 2 months ago
drivers/net/mdio/mdio-octeon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] net: mdio: octeon: use %p for bus id
Posted by Chen Jung Ku 2 months ago
Replace %px with %p to avoid exposing raw kernel pointer values.

Signed-off-by: Chen Jung Ku <ku.loong@gapp.nthu.edu.tw>
---
 drivers/net/mdio/mdio-octeon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mdio/mdio-octeon.c b/drivers/net/mdio/mdio-octeon.c
index cb53dccbde1a..c9c000bb0cd5 100644
--- a/drivers/net/mdio/mdio-octeon.c
+++ b/drivers/net/mdio/mdio-octeon.c
@@ -38,7 +38,7 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
 	oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
 
 	bus->mii_bus->name = KBUILD_MODNAME;
-	snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%px", bus->register_base);
+	snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%p", bus->register_base);
 	bus->mii_bus->parent = &pdev->dev;
 
 	bus->mii_bus->read = cavium_mdiobus_read_c22;
-- 
2.43.0
Re: [PATCH] net: mdio: octeon: use %p for bus id
Posted by Andrew Lunn 2 months ago
On Tue, Apr 14, 2026 at 11:56:52PM +0800, Chen Jung Ku wrote:
> Replace %px with %p to avoid exposing raw kernel pointer values.

What exactly are we giving away here?

                        compatible = "cavium,octeon-3860-mdio";
                        #address-cells = <1>;
                        #size-cells = <0>;
                        reg = <0x11800 0x00001900 0x0 0x40>;

Isn't bus->register_base this well known value?

You also need to think about ABI.

    Andrew
Re: [PATCH] net: mdio: octeon: use %p for bus id
Posted by Russell King (Oracle) 2 months ago
On Tue, Apr 14, 2026 at 06:16:08PM +0200, Andrew Lunn wrote:
> On Tue, Apr 14, 2026 at 11:56:52PM +0800, Chen Jung Ku wrote:
> > Replace %px with %p to avoid exposing raw kernel pointer values.
> 
> What exactly are we giving away here?
> 
>                         compatible = "cavium,octeon-3860-mdio";
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         reg = <0x11800 0x00001900 0x0 0x40>;
> 
> Isn't bus->register_base this well known value?
> 
> You also need to think about ABI.

There isn't ABI here.

        bus->register_base = devm_platform_ioremap_resource(pdev, 0);

        snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%px", bus->register_base);

bus->register_base is the ioremap'd version of the resource, which is
effectively random, and it can be either a 32 or 64-bit hex number
depending on the pointer size. It's an exceedingly bad choice of MDIO
bus ID.

A better more stable choice would be to use the bus address or
dev_name().

Even so, I don't think there's any ABI here as the existing "ID" will
not be stable.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH] net: mdio: octeon: use %p for bus id
Posted by 古鎮榮 2 months ago
Thank you for the clarification. I understand the concern now and will
not pursue this patch further.

Best regards,
Chen Jung Ku

Andrew Lunn <andrew@lunn.ch> 於 2026年4月15日週三 上午12:16寫道:
>
> On Tue, Apr 14, 2026 at 11:56:52PM +0800, Chen Jung Ku wrote:
> > Replace %px with %p to avoid exposing raw kernel pointer values.
>
> What exactly are we giving away here?
>
>                         compatible = "cavium,octeon-3860-mdio";
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         reg = <0x11800 0x00001900 0x0 0x40>;
>
> Isn't bus->register_base this well known value?
>
> You also need to think about ABI.
>
>     Andrew