Subject: Re: [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero()

From: Breno Leitao <[email-masked]>
Date: Fri, 8 May 2026 02:13:49 -0700

On Fri, May 08, 2026 at 04:02:11PM +0800, Chenguang Zhao wrote:
> memchr_inv() returns non-NULL when a byte differs from the given value.
> Return true in that case, not when the scanned words are all zero.
> 
> Signed-off-by: Chenguang Zhao <[email-masked]>

There is no Fixes: tag. It seems the buggy check was introduced in 
commit 10b518d4e6dd ("ethtool: netlink bitset handling").

> ---
>  net/ethtool/bitset.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/bitset.c b/net/ethtool/bitset.c
> index 8bb98d3ea3db..56b0c4867ed2 100644
> --- a/net/ethtool/bitset.c
> +++ b/net/ethtool/bitset.c
> @@ -105,7 +105,7 @@ static bool ethnl_bitmap32_not_zero(const u32 *map, unsigned int start,
>  		start_word++;
>  	}
>  
> -	if (!memchr_inv(map + start_word, '\0',
> +	if (memchr_inv(map + start_word, '\0',
>  			(end_word - start_word) * sizeof(u32)))
>  		return true;

>  	if (end % 32 == 0)

The fix itself looks correct, but is the rest of
ethnl_bitmap32_not_zero() consistent with the documented "true if there
is a non-zero bit in [start, end)" semantics?