From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
Subject: lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
Date: Mon, 30 Mar 2026 20:18:45 +0800 [thread overview]
Message-ID: <202603302040.VStJOW2P-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Kees Cook <kees@kernel.org>
CC: David Gow <davidgow@google.com>
CC: Rae Moar <rmoar@google.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
commit: db6fe4d61ece24193eb4d94a82d967501d53358c lib: Move KUnit tests into tests/ subdirectory
date: 1 year, 2 months ago
:::::: branch date: 14 hours ago
:::::: commit date: 1 year, 2 months ago
config: powerpc64-randconfig-r052-20260330 (https://download.01.org/0day-ci/archive/20260330/202603302040.VStJOW2P-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 054e11d1a17e5ba88bb1a8ef32fad3346e80b186)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202603302040.VStJOW2P-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208
lib/tests/fortify_kunit.c:213:8-9: ERROR: reference preceded by free on line 211
lib/tests/fortify_kunit.c:216:8-9: ERROR: reference preceded by free on line 213
lib/tests/fortify_kunit.c:218:8-9: ERROR: reference preceded by free on line 216
lib/tests/fortify_kunit.c:220:8-9: ERROR: reference preceded by free on line 218
lib/tests/fortify_kunit.c:223:8-9: ERROR: reference preceded by free on line 220
lib/tests/fortify_kunit.c:226:8-9: ERROR: reference preceded by free on line 223
lib/tests/fortify_kunit.c:228:8-9: ERROR: reference preceded by free on line 226
lib/tests/fortify_kunit.c:230:8-9: ERROR: reference preceded by free on line 228
lib/tests/fortify_kunit.c:233:8-9: ERROR: reference preceded by free on line 230
lib/tests/fortify_kunit.c:236:8-9: ERROR: reference preceded by free on line 233
lib/tests/fortify_kunit.c:242:8-9: ERROR: reference preceded by free on line 236
lib/tests/fortify_kunit.c:247:8-9: ERROR: reference preceded by free on line 242
lib/tests/fortify_kunit.c:252:8-9: ERROR: reference preceded by free on line 247
lib/tests/fortify_kunit.c:258:54-55: ERROR: reference preceded by free on line 252
lib/tests/fortify_kunit.c:377:9-10: ERROR: reference preceded by free on line 375
lib/tests/fortify_kunit.c:375:9-10: ERROR: reference preceded by free on line 377
vim +211 lib/tests/fortify_kunit.c
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 201
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 202 #define TEST_kmalloc(checker, expected_size, alloc_size) do { \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 203 gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 204 void *orig; \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 205 size_t len; \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 206 \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 207 checker(expected_size, kmalloc(alloc_size, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 @208 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 209 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 210 kmalloc_node(alloc_size, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 @211 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 212 checker(expected_size, kzalloc(alloc_size, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 213 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 214 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 215 kzalloc_node(alloc_size, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 216 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 217 checker(expected_size, kcalloc(1, alloc_size, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 218 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 219 checker(expected_size, kcalloc(alloc_size, 1, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 220 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 221 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 222 kcalloc_node(1, alloc_size, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 223 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 224 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 225 kcalloc_node(alloc_size, 1, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 226 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 227 checker(expected_size, kmalloc_array(1, alloc_size, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 228 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 229 checker(expected_size, kmalloc_array(alloc_size, 1, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 230 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 231 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 232 kmalloc_array_node(1, alloc_size, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 233 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 234 checker(expected_size, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 235 kmalloc_array_node(alloc_size, 1, gfp, NUMA_NO_NODE), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 236 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 237 \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 238 orig = kmalloc(alloc_size, gfp); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 239 KUNIT_EXPECT_TRUE(test, orig != NULL); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 240 checker((expected_size) * 2, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 241 krealloc(orig, (alloc_size) * 2, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 242 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 243 orig = kmalloc(alloc_size, gfp); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 244 KUNIT_EXPECT_TRUE(test, orig != NULL); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 245 checker((expected_size) * 2, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 246 krealloc_array(orig, 1, (alloc_size) * 2, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 247 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 248 orig = kmalloc(alloc_size, gfp); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 249 KUNIT_EXPECT_TRUE(test, orig != NULL); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 250 checker((expected_size) * 2, \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 251 krealloc_array(orig, (alloc_size) * 2, 1, gfp), \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 252 kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 253 \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 254 len = 11; \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 255 /* Using memdup() with fixed size, so force unknown length. */ \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 256 if (!__builtin_constant_p(expected_size)) \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 257 len += zero_size; \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 258 checker(len, kmemdup("hello there", len, gfp), kfree(p)); \
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 259 } while (0)
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 260 DEFINE_ALLOC_SIZE_TEST_PAIR(kmalloc)
9124a26401483b lib/fortify_kunit.c Kees Cook 2022-09-29 261
:::::: The code at line 211 was first introduced by commit
:::::: 9124a26401483bf2b13a99cb4317dce3f677060f kunit/fortify: Validate __alloc_size attribute results
:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Kees Cook <keescook@chromium.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2026-03-30 12:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 12:18 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-02 7:56 lib/tests/fortify_kunit.c:211:8-9: ERROR: reference preceded by free on line 208 kernel test robot
2025-05-25 6:12 kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202603302040.VStJOW2P-lkp@intel.com \
--to=lkp@intel.com \
--cc=julia.lawall@inria.fr \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.