Netdev List
 help / color / mirror / Atom feed
* [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero()
@ 2026-05-08  8:02 Chenguang Zhao
  2026-05-08  9:13 ` Breno Leitao
  0 siblings, 1 reply; 2+ messages in thread
From: Chenguang Zhao @ 2026-05-08  8:02 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, David S. Miller, Eric Dumazet,
	Paolo Abeni
  Cc: Chenguang Zhao, Simon Horman, Maxime Chevallier, netdev

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 <zhaochenguang@kylinos.cn>
---
 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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero()
  2026-05-08  8:02 [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero() Chenguang Zhao
@ 2026-05-08  9:13 ` Breno Leitao
  0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-05-08  9:13 UTC (permalink / raw)
  To: Chenguang Zhao
  Cc: Andrew Lunn, Jakub Kicinski, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, Maxime Chevallier, netdev

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 <zhaochenguang@kylinos.cn>

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?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-08  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08  8:02 [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero() Chenguang Zhao
2026-05-08  9:13 ` Breno Leitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox