Re: [PATCH] net: ethernet: fix NULL dereference in nixge_recv()

From: Przemek Kitszel
Date: Wed Dec 11 2024 - 04:28:40 EST


On 12/11/24 09:34, Ma Ke wrote:
In function nixge_recv() dereference of NULL pointer priv->rx_bd_v is
possible for the case of its allocation failure in netdev_priv(ndev).

please be more precise about the case, rx_bd_v is not set during
netdev(w/priv) allocation

the embedded priv part is allocated together with the netdev, in the
.probe()


Move while() loop with priv->rx_bd_v dereference under the check for
its validity.

this style has some benefits, but in the kernel we prefer the early
return:
if (!priv->rx_bd_v)
return 0;

instead of touching a whole function


Cc: stable@xxxxxxxxxxxxxxx
Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: Ma Ke <make_ruc2021@xxxxxxx>
---
drivers/net/ethernet/ni/nixge.c | 86 ++++++++++++++++-----------------
1 file changed, 43 insertions(+), 43 deletions(-)