Re: [PATCH] kunit: run test suites only after module initialization completes

2023-10-16 Thread Jinjie Ruan
On 2023/10/17 4:35, Marco Pagani wrote: > Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in > kunit_free_suite_set()") is causing all test suites to run (when > built as modules) while still in MODULE_STATE_COMING. In that state, > test modules are not fully initialized and lack sysfs k

[PATCH RESEND 3/3] kunit: Init and run test suites in the right state

2023-09-28 Thread Jinjie Ruan
Fixes: 2810c1e99867 ("kunit: Fix wild-memory-access bug in kunit_free_suite_set()") Reported-by: Marco Pagani Signed-off-by: Jinjie Ruan --- lib/kunit/test.c | 25 - 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/kunit/test.c b/lib/kunit/test.c in

[PATCH RESEND 2/3] kunit: Return error from kunit_module_init()

2023-09-28 Thread Jinjie Ruan
code behind it is dead code. so return err if it fails. Signed-off-by: Jinjie Ruan --- lib/kunit/test.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 29a5f5ea8112..145f70219f46 100644 --- a/lib/kunit/test.c +++ b/lib/

[PATCH RESEND 1/3] kunit: Make the cases sequence more reasonable for kunit_module_notify()

2023-09-28 Thread Jinjie Ruan
The module has a normal sequence from MODULE_STATE_COMING to MODULE_STATE_LIVE and to MODULE_STATE_GOING, and eventually MODULE_STATE_UNFORMED. The original order of cases is confusing and misleading. Signed-off-by: Jinjie Ruan --- lib/kunit/test.c | 6 +++--- 1 file changed, 3 insertions(+), 3

[PATCH RESEND 0/3] kunit: Init and run test suites in the right state

2023-09-28 Thread Jinjie Ruan
The original order of cases in kunit_module_notify() is confusing and misleading. And the best practice is return the err code from MODULE_STATE_COMING func. And the test suits should be executed when notify MODULE_STATE_LIVE. Jinjie Ruan (3): kunit: Make the cases sequence more reasonable

[PATCH v4 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-27 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the copy pointer has been moved. So it should free the original copy's backup copy_start. Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()") Signed-off-

[PATCH v4 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-27 Thread Jinjie Ruan
87e304>] el0_svc_common.constprop.1+0x68/0xe0 [<9d8ad866>] do_el0_svc+0x1c/0x28 [<5b83c607>] el0_svc+0x3c/0xc4 Fixes: a127b154a8f2 ("kunit: tool: allow filtering test cases via glob") Signed-off-by: Jinjie Ruan Reviewed-by: Rae Moar Reviewed-b

[PATCH v4 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-27 Thread Jinjie Ruan
t_test_suites") Fixes: 76066f93f1df ("kunit: add tests for filtering attributes") Signed-off-by: Jinjie Ruan Suggested-by: Rae Moar Reviewed-by: David Gow Suggested-by: David Gow Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202309142251.uj8saazv-..

[PATCH v4 0/4] kunit: Fix some bugs in kunit

2023-09-27 Thread Jinjie Ruan
to use kunit_free_suite_set() for 4th patch. - Update the commit message for the 4th patch. Changes in v2: - Add Reviewed-by. - Add the memory leak backtrace for the 4th patch. - Remove the unused func kernel test robot noticed for the 4th patch. - Update the commit message for the 4th patch. Jinjie R

[PATCH v4 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-27 Thread Jinjie Ruan
the filtered_suite and filtered_suite->test_cases so far. And change kmalloc_array of copy to kcalloc to Clear the copy to make the kfree safe. Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes") Signed-off-by: Jinjie Ruan Reviewed-by: Rae Moar Reviewed-by: David Gow --- v4: - Cor

[PATCH v3 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-22 Thread Jinjie Ruan
860 [] kunit_filter_suites+0x82f/0xcc0 [] filter_attr_skip_test+0x133/0x6e0 [] kunit_generic_run_threadfn_adapter+0x4a/0x90 [] kthread+0x2b6/0x380 [] ret_from_fork+0x2d/0x70 [] ret_from_fork_asm+0x11/0x20 Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kun

[PATCH v3 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-22 Thread Jinjie Ruan
the filtered_suite and filtered_suite->test_cases so far. And change kmalloc_array of copy to kcalloc to Clear the copy to make the kfree safe. Fixes: 5d31f71efcb6 ("kunit: add kunit.filter_glob cmdline option to filter suites") Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes&qu

[PATCH v3 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-22 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the copy pointer has been moved. So it should free the original copy's backup copy_start. Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()") Signed-off-

[PATCH v3 0/4] kunit: Fix some bugs in kunit

2023-09-22 Thread Jinjie Ruan
y leak backtrace for the 4th patch. - Remove the unused func kernel test robot noticed for the 4th patch. - Update the commit message for the 4th patch. Jinjie Ruan (4): kunit: Fix missed memory release in kunit_free_suite_set() kunit: Fix the wrong kfree of copy for kunit_filter_suites()

[PATCH v3 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-22 Thread Jinjie Ruan
87e304>] el0_svc_common.constprop.1+0x68/0xe0 [<9d8ad866>] do_el0_svc+0x1c/0x28 [<5b83c607>] el0_svc+0x3c/0xc4 Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites") Fixes: b67abaad4d25 ("kunit: Allo

[PATCH v2 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-20 Thread Jinjie Ruan
the filtered_suite and filtered_suite->test_cases so far. And change kmalloc_array of copy to kcalloc to Clear the copy to make the kfree safe. Fixes: 5d31f71efcb6 ("kunit: add kunit.filter_glob cmdline option to filter suites") Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes&qu

[PATCH v2 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-20 Thread Jinjie Ruan
fork_asm+0x11/0x20 Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites") Signed-off-by: Jinjie Ruan Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202309142251.uj8saazv-...@intel.com/ --- v2: - Add the memory leak b

[PATCH v2 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-20 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the copy pointer has been moved. So it should free the original copy's backup copy_start. Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()") Signed-off-

[PATCH v2 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-20 Thread Jinjie Ruan
87e304>] el0_svc_common.constprop.1+0x68/0xe0 [<9d8ad866>] do_el0_svc+0x1c/0x28 [<5b83c607>] el0_svc+0x3c/0xc4 Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites") Fixes: b67abaad4d25 ("kunit: Allo

[PATCH v2 0/4] kunit: Fix some bugs in kunit

2023-09-20 Thread Jinjie Ruan
or the 4th patch. Jinjie Ruan (4): kunit: Fix missed memory release in kunit_free_suite_set() kunit: Fix the wrong kfree of copy for kunit_filter_suites() kunit: Fix possible memory leak in kunit_filter_suites() kunit: test: Fix the possible memory leak in executor_test lib/kunit/exec

[PATCH v3 2/2] mm/damon/core-test: Fix memory leak in damon_new_ctx()

2023-09-18 Thread Jinjie Ruan
readfn_adapter+0x20/0x2c [<3c3e9211>] kthread+0x124/0x130 [<28f85bdd>] ret_from_fork+0x10/0x20 Fixes: d1836a3b2a9a ("mm/damon/core-test: initialise context before test in damon_test_set_attrs()") Fixes: 4f540f5ab4f2 ("mm/damon/core-test: ad

[PATCH v3 1/2] mm/damon/core-test: Fix memory leak in damon_new_region()

2023-09-18 Thread Jinjie Ruan
uot;mm/damon: add kunit tests") Fixes: f4c978b6594b ("mm/damon/core-test: add a test for damon_update_monitoring_results()") Signed-off-by: Jinjie Ruan Reviewed-by: SeongJae Park --- v3: - Update the commit message to be more accurate. - Add Reviewed-by. v2: - Replace the damon_del_re

[PATCH v3 0/2] mm/damon/core-test: Fix memory leaks in core-test

2023-09-18 Thread Jinjie Ruan
e the damon_del_region() with damon_destroy_region() rather than calling damon_free_region(). - Update the commit message. Jinjie Ruan (2): mm/damon/core-test: Fix memory leak in damon_new_region() mm/damon/core-test: Fix memory leak in damon_new_ctx() mm/damon/core-test.h | 8 +++- 1

[PATCH v2 0/2] mm/damon/core-test: Fix memory leaks in core-test

2023-09-18 Thread Jinjie Ruan
message. Jinjie Ruan (2): mm/damon/core-test: Fix memory leak in damon_new_region() mm/damon/core-test: Fix memory leak in damon_new_ctx() mm/damon/core-test.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.34.1

[PATCH v2 1/2] mm/damon/core-test: Fix memory leak in damon_new_region()

2023-09-18 Thread Jinjie Ruan
85bdd>] ret_from_fork+0x10/0x20 Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Fixes: f4c978b6594b ("mm/damon/core-test: add a test for damon_update_monitoring_results()") Signed-off-by: Jinjie Ruan --- v2: - Replace the damon_del_region() with damon_destroy_region()

[PATCH v2 2/2] mm/damon/core-test: Fix memory leak in damon_new_ctx()

2023-09-18 Thread Jinjie Ruan
readfn_adapter+0x20/0x2c [<3c3e9211>] kthread+0x124/0x130 [<28f85bdd>] ret_from_fork+0x10/0x20 Fixes: d1836a3b2a9a ("mm/damon/core-test: initialise context before test in damon_test_set_attrs()") Fixes: 4f540f5ab4f2 ("mm/damon/core-tes

[PATCH RESEND 1/2] mm/damon/core-test: Fix memory leak in damon_new_region()

2023-09-17 Thread Jinjie Ruan
00028f85bdd>] ret_from_fork+0x10/0x20 Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Fixes: f4c978b6594b ("mm/damon/core-test: add a test for damon_update_monitoring_results()") Signed-off-by: Jinjie Ruan --- mm/damon/core-test.h | 3 +++ 1 file changed, 3 insertions(

[PATCH RESEND 2/2] mm/damon/core-test: Fix memory leak in damon_new_ctx()

2023-09-17 Thread Jinjie Ruan
c_run_threadfn_adapter+0x20/0x2c [<3c3e9211>] kthread+0x124/0x130 [<28f85bdd>] ret_from_fork+0x10/0x20 Fixes: d1836a3b2a9a ("mm/damon/core-test: initialise context before test in damon_test_set_attrs()") Fixes: 4f540f5ab4f2 ("mm/damon/core-t

[PATCH RESEND 0/2] mm/damon/core-test: Fix memory leaks in core-test

2023-09-17 Thread Jinjie Ruan
There are a few memory leak in core-test which is detected by kmemleak, the patch set fix the above issue. Jinjie Ruan (2): mm/damon/core-test: Fix memory leak in damon_new_region() mm/damon/core-test: Fix memory leak in damon_new_ctx() mm/damon/core-test.h | 7 +++ 1 file changed, 7

[PATCH] kunit: Fix a null-ptr-deref bug in kunit_run_case_catch_errors()

2023-09-15 Thread Jinjie Ruan
600 Kernel panic - not syncing: Fatal exception Dumping ftrace buffer: (ftrace buffer empty) Kernel Offset: disabled Rebooting in 1 seconds.. Fixes: 55e8c1b49ac5 ("kunit: Always run cleanup from a test kthread") Signed-off-by: Jinjie Ruan --- include/kunit/try-catch.h | 2 +- lib

[PATCH 4/4] kunit: test: Fix the possible memory leak in executor_test

2023-09-14 Thread Jinjie Ruan
396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites") Signed-off-by: Jinjie Ruan --- lib/kunit/executor_test.c | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/kunit/executor_test.c b/lib/kunit/executor_test.c in

[PATCH 3/4] kunit: Fix possible memory leak in kunit_filter_suites()

2023-09-14 Thread Jinjie Ruan
the filtered_suite and filtered_suite->test_cases so far. And change kmalloc_array of copy to kcalloc to Clear the copy to make the kfree safe. Fixes: 5d31f71efcb6 ("kunit: add kunit.filter_glob cmdline option to filter suites") Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes&qu

[PATCH 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()

2023-09-14 Thread Jinjie Ruan
If the outer layer for loop is iterated more than once and it fails not in the first iteration, the copy pointer has been moved. So it should free the original copy's backup copy_start. Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()") Signed-off-

[PATCH 1/4] kunit: Fix missed memory release in kunit_free_suite_set()

2023-09-14 Thread Jinjie Ruan
87e304>] el0_svc_common.constprop.1+0x68/0xe0 [<9d8ad866>] do_el0_svc+0x1c/0x28 [<5b83c607>] el0_svc+0x3c/0xc4 Fixes: e5857d396f35 ("kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites") Fixes: b67abaad4d25 ("kunit: Allow kun

[PATCH 0/4] kunit: Fix some bugs in kunit

2023-09-14 Thread Jinjie Ruan
If kunit_filter_suites() succeeds, not only copy but also filtered_suite and filtered_suite->test_cases should be freed. Jinjie Ruan (4): kunit: Fix missed memory release in kunit_free_suite_set() kunit: Fix the wrong kfree of copy for kunit_filter_suites() kunit: Fix possible memory l