Netdev List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Chenguang Zhao <zhaochenguang@kylinos.cn>
Cc: Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Maxime Chevallier <maxime.chevallier@bootlin.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] ethtool: fix inverted memchr_inv condition in ethnl_bitmap32_not_zero()
Date: Fri, 8 May 2026 02:13:49 -0700	[thread overview]
Message-ID: <af2o77Fbou5pnBKy@gmail.com> (raw)
In-Reply-To: <20260508080211.636177-1-zhaochenguang@kylinos.cn>

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?


      reply	other threads:[~2026-05-08  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af2o77Fbou5pnBKy@gmail.com \
    --to=leitao@debian.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zhaochenguang@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox