Re: [PATCH net v2] net/mctp: publish the mctp_dev only after it is initialised

From: Eric Dumazet

Date: Tue Sep 22 2026 - 10:30:37 EST


On Tue, Sep 22, 2026 at 3:19 PM Binbin Deng <18983559317@xxxxxxx> wrote:
>
> From: Binbin Deng <18983559317@xxxxxxx>
>
> mctp_add_dev() links the new mctp_dev into dev->mctp_ptr before mdev->dev
> is assigned, so a reader that picks the device up in that window
> dereferences a net_device pointer that is still NULL:
>
>

> Fix by publishing only once the object is fully initialised:
> __mctp_dev_get() runs under rcu_read_lock() only and hands
> this object to readers as soon as mctp_ptr is assigned, so
> they must never observe mdev->dev == NULL.
>
> Fixes: 583be982d934 ("mctp: Add device handling and netlink interface")
> Signed-off-by: Binbin Deng <18983559317@xxxxxxx>
> ---

Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>

Please next time wait ~24 hours before sending a new version.

Details in Documentation/process/maintainer-netdev.rst