Kunit test function for damos_set_filters_default_reject() allocates two
'struct damos_filter' objects and not deallocates those, so that the
memory for the two objects are leaked for every time the test runs.  Fix
this by deallocating those objects at the end of the test code.

Fixes: 094fb14913c7 ("mm/damon/tests/core-kunit: add a test for 
damos_set_filters_default_reject()")
Cc: <[email protected]> # 6.16.x
Signed-off-by: SeongJae Park <[email protected]>
---
 mm/damon/tests/core-kunit.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 51369e35298b..69ca44f9270b 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -598,6 +598,9 @@ static void damon_test_set_filters_default_reject(struct 
kunit *test)
         */
        KUNIT_EXPECT_EQ(test, scheme.core_filters_default_reject, false);
        KUNIT_EXPECT_EQ(test, scheme.ops_filters_default_reject, true);
+
+       damos_free_filter(anon_filter);
+       damos_free_filter(target_filter);
 }
 
 static struct kunit_case damon_test_cases[] = {
-- 
2.47.3

Reply via email to