Patch "kunit: Fix missed memory release in kunit_free_suite_set()" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kunit: Fix missed memory release in kunit_free_suite_set()

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kunit-fix-missed-memory-release-in-kunit_free_suite_.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5904ff20efbfe624039fbd40858bbe05b414665a
Author: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Date:   Wed Sep 27 17:03:47 2023 +0800

    kunit: Fix missed memory release in kunit_free_suite_set()
    
    [ Upstream commit a6074cf0126b0bee51ab77a15930dc24a4d5db90 ]
    
    modprobe cpumask_kunit and rmmod cpumask_kunit, kmemleak detect
    a suspected memory leak as below.
    
    If kunit_filter_suites() in kunit_module_init() succeeds, the
    suite_set.start will not be NULL and the kunit_free_suite_set() in
    kunit_module_exit() should free all the memory which has not
    been freed. However the test_cases in suites is left out.
    
    unreferenced object 0xffff54ac47e83200 (size 512):
      comm "modprobe", pid 592, jiffies 4294913238 (age 1367.612s)
      hex dump (first 32 bytes):
        84 13 1a f0 d3 b6 ff ff 30 68 1a f0 d3 b6 ff ff  ........0h......
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<000000008dec63a2>] slab_post_alloc_hook+0xb8/0x368
        [<00000000ec280d8e>] __kmem_cache_alloc_node+0x174/0x290
        [<00000000896c7740>] __kmalloc+0x60/0x2c0
        [<000000007a50fa06>] kunit_filter_suites+0x254/0x5b8
        [<0000000078cc98e2>] kunit_module_notify+0xf4/0x240
        [<0000000033cea952>] notifier_call_chain+0x98/0x17c
        [<00000000973d05cc>] notifier_call_chain_robust+0x4c/0xa4
        [<000000005f95895f>] blocking_notifier_call_chain_robust+0x4c/0x74
        [<0000000048e36fa7>] load_module+0x1a2c/0x1c40
        [<0000000004eb8a91>] init_module_from_file+0x94/0xcc
        [<0000000037dbba28>] idempotent_init_module+0x184/0x278
        [<00000000161b75cb>] __arm64_sys_finit_module+0x68/0xa8
        [<000000006dc1669b>] invoke_syscall+0x44/0x100
        [<00000000fa87e304>] el0_svc_common.constprop.1+0x68/0xe0
        [<000000009d8ad866>] do_el0_svc+0x1c/0x28
        [<000000005b83c607>] el0_svc+0x3c/0xc4
    
    Fixes: a127b154a8f2 ("kunit: tool: allow filtering test cases via glob")
    Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
    Reviewed-by: Rae Moar <rmoar@xxxxxxxxxx>
    Reviewed-by: David Gow <davidgow@xxxxxxxxxx>
    Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c
index 74982b83707ca..05ac4cdb6806a 100644
--- a/lib/kunit/executor.c
+++ b/lib/kunit/executor.c
@@ -102,8 +102,10 @@ static void kunit_free_suite_set(struct suite_set suite_set)
 {
 	struct kunit_suite * const *suites;
 
-	for (suites = suite_set.start; suites < suite_set.end; suites++)
+	for (suites = suite_set.start; suites < suite_set.end; suites++) {
+		kfree((*suites)->test_cases);
 		kfree(*suites);
+	}
 	kfree(suite_set.start);
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux