damon.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: initialize damon_target->list in damon_new_target()
@ 2022-10-02 19:31 SeongJae Park
  2022-10-03  6:18 ` Hyeonggon Yoo
  0 siblings, 1 reply; 2+ messages in thread
From: SeongJae Park @ 2022-10-02 19:31 UTC (permalink / raw)
  To: akpm; +Cc: damon, linux-mm, linux-kernel, SeongJae Park, Hyeonggon Yoo

'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;
 }
-- 
2.25.1


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

end of thread, other threads:[~2022-10-03  6:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 19:31 [PATCH] mm/damon/core: initialize damon_target->list in damon_new_target() SeongJae Park
2022-10-03  6:18 ` Hyeonggon Yoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).