Subject: Re: [PATCH net-next v2 8/8] bng_en: implement ndo_get_stats64

From: Jakub Kicinski <[email-masked]>
Date: Thu, 26 Feb 2026 17:22:07 -0800

On Thu, 26 Feb 2026 23:51:33 +0530 Bhargava Marreddy wrote:
> +	set_bit(BNGE_STATE_READ_STATS, &bn->state);
> +	/* Make sure bnge_close_core() sees that we are reading stats before
> +	 * we check the BNGE_STATE_OPEN flag.
> +	 */
> +	smp_mb__after_atomic();
> +	if (!test_bit(BNGE_STATE_OPEN, &bd->state)) {
> +		clear_bit(BNGE_STATE_READ_STATS, &bn->state);
> +		*stats = bn->net_stats_prev;
> +		return;
> +	}

There can be multiple concurrent readers. Two enter, first one gets
stalled second one exits clearing the bit, close frees the memory,
second reader proceeds to hit the NULL pointers.

Again, please don't try to invent synchronization primitives.
You can probably use RCU here.
-- 
pw-bot: cr