linux/mm/damon
Badari Pulavarty d26f607036 mm/damon/dbgfs: avoid duplicate context directory creation
When user tries to create a DAMON context via the DAMON debugfs interface
with a name of an already existing context, the context directory creation
fails but a new context is created and added in the internal data
structure, due to absence of the directory creation success check.  As a
result, memory could leak and DAMON cannot be turned on.  An example test
case is as below:

    # cd /sys/kernel/debug/damon/
    # echo "off" >  monitor_on
    # echo paddr > target_ids
    # echo "abc" > mk_context
    # echo "abc" > mk_context
    # echo $$ > abc/target_ids
    # echo "on" > monitor_on  <<< fails

Return value of 'debugfs_create_dir()' is expected to be ignored in
general, but this is an exceptional case as DAMON feature is depending
on the debugfs functionality and it has the potential duplicate name
issue.  This commit therefore fixes the issue by checking the directory
creation failure and immediately return the error in the case.

Link: https://lkml.kernel.org/r/20220821180853.2400-1-sj@kernel.org
Fixes: 75c1c2b53c ("mm/damon/dbgfs: support multiple contexts")
Signed-off-by: Badari Pulavarty <badari.pulavarty@intel.com>
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[ 5.15.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-08-28 14:02:45 -07:00
..
core-test.h mm/damon/core-test: add a kunit test case for ops registration 2022-04-29 14:37:00 -07:00
core.c mm/damon/vaddr: move 'damon_set_regions()' to core 2022-05-13 07:20:08 -07:00
dbgfs-test.h mm/damon/dbgfs-test: fix is_target_id() change 2022-03-22 15:57:12 -07:00
dbgfs.c mm/damon/dbgfs: avoid duplicate context directory creation 2022-08-28 14:02:45 -07:00
Kconfig mm/damon: introduce DAMON-based LRU-lists Sorting 2022-07-03 18:08:43 -07:00
lru_sort.c mm/damon/lru_sort: fix potential memory leak in damon_lru_sort_init() 2022-07-17 17:14:27 -07:00
Makefile mm/damon: introduce DAMON-based LRU-lists Sorting 2022-07-03 18:08:43 -07:00
ops-common.c mm/damon/schemes: add 'LRU_PRIO' DAMOS action 2022-07-03 18:08:42 -07:00
ops-common.h mm/damon/schemes: add 'LRU_PRIO' DAMOS action 2022-07-03 18:08:42 -07:00
paddr.c mm/damon/schemes: add 'LRU_DEPRIO' action 2022-07-03 18:08:43 -07:00
reclaim.c mm/damon/reclaim: fix potential memory leak in damon_reclaim_init() 2022-07-29 18:07:15 -07:00
sysfs.c mm/damon/schemes: add 'LRU_DEPRIO' action 2022-07-03 18:08:43 -07:00
vaddr-test.h mm/damon/vaddr: remove damon_va_apply_three_regions() 2022-05-13 07:20:08 -07:00
vaddr.c mm/damon: use set_huge_pte_at() to make huge pte old 2022-07-03 15:42:32 -07:00