Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext4: fix possible null-ptr-deref in extents_kunit_exit()

There's issue as follows:
KASAN: null-ptr-deref in range [0x00000000000002c0-0x00000000000002c7]
Tainted: [E]=UNSIGNED_MODULE, [N]=TEST
RIP: 0010:extents_kunit_exit+0x2e/0xc0 [ext4_test]
Call Trace:
<TASK>
kunit_try_run_case_cleanup+0xbc/0x100 [kunit]
kunit_generic_run_threadfn_adapter+0x89/0x100 [kunit]
kthread+0x408/0x540
ret_from_fork+0xa76/0xdf0
ret_from_fork_asm+0x1a/0x30

Above issue happens as extents_kunit_init() init testcase failed.
So test if testcase is inited success.

Fixes: cb1e0c1d1fad ("ext4: kunit tests for extent splitting and conversion")
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://patch.msgid.link/20260330133035.287842-5-yebin@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Ye Bin and committed by
Theodore Ts'o
ca78c31a 17f73c95

+5 -2
+5 -2
fs/ext4/extents-test.c
··· 142 142 143 143 static void extents_kunit_exit(struct kunit *test) 144 144 { 145 - struct super_block *sb = k_ctx.k_ei->vfs_inode.i_sb; 146 - struct ext4_sb_info *sbi = sb->s_fs_info; 145 + struct ext4_sb_info *sbi; 147 146 147 + if (!k_ctx.k_ei) 148 + return; 149 + 150 + sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info; 148 151 ext4_es_unregister_shrinker(sbi); 149 152 deactivate_super(sbi->s_sb); 150 153 kfree(sbi);