[bug report] kunit: test: Fix the possible memory leak in executor_test

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

 



Hello Jinjie Ruan,

The patch 8040345fdae4: "kunit: test: Fix the possible memory leak in
executor_test" from Sep 27, 2023 (linux-next), leads to the following
Smatch static checker warning:

	lib/kunit/executor_test.c:276 free_suite_set_at_end()
	error: potential null dereference 'free'.  (kzalloc returns null)

lib/kunit/executor_test.c
    268 static void free_suite_set_at_end(struct kunit *test, const void *to_free)
    269 {
    270         struct kunit_suite_set *free;
    271 
    272         if (!((struct kunit_suite_set *)to_free)->start)
    273                 return;
    274 
    275         free = kzalloc(sizeof(struct kunit_suite_set), GFP_KERNEL);
--> 276         *free = *(struct kunit_suite_set *)to_free;
                ^^^^^
Static checkers always try to encourage people to check allocations.

    277 
    278         kunit_add_action(test, free_suite_set, (void *)free);
    279 }

regards,
dan carpenter



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux