Re: [PATCH v2] net: ethernet: fix NULL dereference in nixge_recv()
From: Eric Dumazet
Date: Tue Dec 17 2024 - 07:41:36 EST
On Tue, Dec 17, 2024 at 12:25 PM Ma Ke <make_ruc2021@xxxxxxx> wrote:
>
> Due to the failure of allocating the variable 'priv' in
> netdev_priv(ndev), this could result in 'priv->rx_bd_v' not being set
> during the allocation process of netdev_priv(ndev), which could lead
> to a null pointer dereference.
>
> Move while() loop with 'priv->rx_bd_v' dereference after the check
> for its validity.
>
> Found by code review.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
> Signed-off-by: Ma Ke <make_ruc2021@xxxxxxx>
> ---
> Changes in v2:
> - modified the bug description as suggestions;
> - modified the patch as the code style suggested.
I really do not understand this patch.
if priv->rx_bd_v allocation failed, surely the device is not
operational, because nixge_hw_dma_bd_init() returns -ENOMEM