mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] XArray: Fix xa_to_node by adding xa_is_node
Date: Mon, 18 Oct 2021 21:06:20 +0100	[thread overview]
Message-ID: <YW3TvBMSwYmbMPdD@casper.infradead.org> (raw)
In-Reply-To: <1634028170-1753612-1-git-send-email-jiasheng@iscas.ac.cn>

On Tue, Oct 12, 2021 at 08:42:50AM +0000, Jiasheng Jiang wrote:
> Directly using xa_to_node may lead to the compulsory type
> conversion of unknown type,which is unsafe.
> So it might be better that adding xa_is_node before.

No.  This is test code, and it knows what it's doing.
I suppose we could add an XA_BUG_ON(xa, !xa_is_node(xa_head(xa)));
but that seems pointless.  This patch is definitely wrong.

> Fixes: 58d6ea3 ("xarray: Add XArray unconditional store operations")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  lib/test_xarray.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/test_xarray.c b/lib/test_xarray.c
> index 8b1c318..7ad3d51 100644
> --- a/lib/test_xarray.c
> +++ b/lib/test_xarray.c
> @@ -606,8 +606,10 @@ static noinline void check_multi_store(struct xarray *xa)
>  	XA_BUG_ON(xa, xa_load(xa, 1) != xa_mk_value(0));
>  	XA_BUG_ON(xa, xa_load(xa, 2) != NULL);
>  	rcu_read_lock();
> -	XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 2);
> -	XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2);
> +	if (xa_is_node(xa_head(xa))) {
> +		XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 2);
> +		XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2);
> +	}
>  	rcu_read_unlock();
>  
>  	/* Storing adjacent to the value does not alter the value */
> -- 
> 2.7.4
> 

      reply	other threads:[~2021-10-18 20:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  8:42 Jiasheng Jiang
2021-10-18 20:06 ` Matthew Wilcox [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=YW3TvBMSwYmbMPdD@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®