linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: SeongJae Park <sj@kernel.org>
Cc: akpm@linux-foundation.org, damon@lists.linux.dev,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon/core: initialize damon_target->list in damon_new_target()
Date: Mon, 3 Oct 2022 15:18:09 +0900	[thread overview]
Message-ID: <Yzp+oTYs4s7stUIC@hyeyoo> (raw)
In-Reply-To: <20221002193130.8227-1-sj@kernel.org>

On Sun, Oct 02, 2022 at 07:31:30PM +0000, SeongJae Park wrote:
> 'struct damon_target' creation function, 'damon_new_target()' is not
> initializing its '->list' field, unlike other DAMON structs creator
> functions such as 'damon_new_region()'.  Normal users of
> 'damon_new_target()' initializes the field by adding the target to DAMON
> context's targets list, but some code could access the uninitialized
> field.
> 
> This commit avoids the case by initializing the field in
> 'damon_new_target()'.
> 
> Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> Fixes: f23b8eee1871 ("mm/damon/core: implement region-based sampling")
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
> 
>  mm/damon/core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 1d952fa7ba3e..1e6691771a95 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -345,6 +345,7 @@ struct damon_target *damon_new_target(void)
>  	t->pid = NULL;
>  	t->nr_regions = 0;
>  	INIT_LIST_HEAD(&t->regions_list);
> +	INIT_LIST_HEAD(&t->list);
>  
>  	return t;
>  }

I tried again with it and this fixes the bug I reported.
Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Thank you for such a quick fix!

> -- 
> 2.25.1
> 

-- 
Thanks,
Hyeonggon


      reply	other threads:[~2022-10-03  6:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 19:31 SeongJae Park
2022-10-03  6:18 ` Hyeonggon Yoo [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=Yzp+oTYs4s7stUIC@hyeyoo \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@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