Re: [PATCH net-next v2 4/4] netdevsim: account dropped packet length in stats on queue free

From: Jakub Kicinski
Date: Fri Jun 13 2025 - 10:57:17 EST


On Fri, 13 Jun 2025 07:47:11 -0700 Breno Leitao wrote:
> > static void nsim_queue_free(struct nsim_rq *rq)
> > {
> > + struct net_device *dev = rq->napi.dev;
> > +
> > hrtimer_cancel(&rq->napi_timer);
> > + dev_dstats_rx_dropped_add(dev, rq->skb_queue.qlen);
>
> This is wrong and it will cause the kernel to crash in some cases, given
> we can get here with dev == NULL, in the following path:

It's probably because NAPI wasn't registered yet in some paths.
You can pass dev in from the callers, it always exists, and all
callers have it.
--
pw-bot: cr