Re: [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path

From: Daniel Machon

Date: Mon Nov 23 2026 - 04:00:58 EST


> The peer flow add path hands the duplicated flow over to the origin
> flow before it looks up the peer entry for the peer vhca_id. When
> that entry is missing, the function returns -ENODEV, and the caller
> then deletes the duplicated flow with list_del() on its peer node, a
> list head that was never initialised and never linked. list_del() on
> such a node writes through the NULL page.
>
> Look the peer entry up before the duplicated flow is created and
> handed over, so that a missing entry is reported without leaving a
> duplicated flow behind. The entry cannot change in between: the peer
> loop in mlx5e_add_fdb_flow() holds the devcom component's read lock,
> and peer_flows entries are only stored and erased by the pair and
> unpair events, under its write lock.
>
> Found by code review and not reproduced; compile-tested only.
>
> AI assistance was used.
>
> Fixes: 9d608a40c2d4 ("net/mlx5e: TC, track peer flows in a vhca_id xarray")
> Signed-off-by: Zhao Li <enderaoelyther@xxxxxxxxx>

Reviewed-by: Daniel Machon <daniel.machon@xxxxxxxxxxxxx>