[PATCH net] net: thunder_bgx: Fix netdev structure allocation
Simon Horman
horms at kernel.org
Mon Aug 12 09:25:05 PDT 2024
On Mon, Aug 12, 2024 at 03:13:22PM +0100, Marc Zyngier wrote:
> Commit 94833addfaba ("net: thunderx: Unembed netdev structure") had
> a go at dynamically allocating the netdev structures for the thunderx_bgx
> driver. This change results in my ThunderX box catching fire (to be fair,
> it is what it does best).
(I saw that :)
> The issues with this change are that:
>
> - bgx_lmac_enable() is called *after* bgx_acpi_register_phy() and
> bgx_init_of_phy(), both expecting netdev to be a valid pointer.
>
> - bgx_init_of_phy() populates the MAC addresses for *all* LMACs
> attached to a given BGX instance, and thus needs netdev for each of
> them to have been allocated.
>
> There is a few things to be said about how the driver mixes LMAC and
> BGX states which leads to this sorry state, but that's beside the point.
>
> To address this, go back to a situation where all netdev structures
> are allocated before the driver starts relying on them, and move the
> freeing of these structures to driver removal. Someone brave enough
> can always go and restructure the driver if they want.
>
> Fixes: 94833addfaba ("net: thunderx: Unembed netdev structure")
> Signed-off-by: Marc Zyngier <maz at kernel.org>
Reviewed-by: Simon Horman <horms at kernel.org>
More information about the linux-arm-kernel
mailing list