Re: [PATCH net] net: macb: fix NULL pointer dereference on unbind with fixed-link
From: Théo Lebrun
Date: Thu Sep 03 2026 - 04:47:59 EST
Hi Nicolai,
On Thu Sep 3, 2026 at 9:23 AM CEST, Nicolai Buchwitz wrote:
> On 2.9.2026 12:28, Vineeth Karumanchi wrote:
>> @@ -5971,8 +5971,10 @@ static int macb_probe(struct platform_device
>> *pdev)
>> macb_free_tieoff(bp);
>>
>> err_out_unregister_mdio:
>> - mdiobus_unregister(bp->mii_bus);
>> - mdiobus_free(bp->mii_bus);
>> + if (bp->mii_bus) {
>> + mdiobus_unregister(bp->mii_bus);
>> + mdiobus_free(bp->mii_bus);
>> + }
>>
>> err_out_phy_exit:
>> phy_exit(bp->phy);
>> @@ -6001,8 +6003,10 @@ static void macb_remove(struct platform_device
>> *pdev)
>> unregister_netdev(netdev);
>> macb_free_tieoff(bp);
>> phy_exit(bp->phy);
>> - mdiobus_unregister(bp->mii_bus);
>> - mdiobus_free(bp->mii_bus);
>> + if (bp->mii_bus) {
>> + mdiobus_unregister(bp->mii_bus);
>> + mdiobus_free(bp->mii_bus);
>> + }
>
> nit: replica of the code from above, but also not really worth a helper?
Agreed that the helper is overblown!
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com