From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: kernel/trace/ftrace.c:3437 add_next_hash() warn: variable dereferenced before check 'filter_hash' (see line 3436)
Date: Mon, 14 Apr 2025 22:30:15 +0800 [thread overview]
Message-ID: <202504142245.rmvWCoRj-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Steven Rostedt <rostedt@goodmis.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8ffd015db85fea3e15a77027fda6c02ced4d2444
commit: 0ae6b8ce200da00a78f33c055fdc4fe3225d22ec ftrace: Fix accounting of subop hashes
date: 3 days ago
:::::: branch date: 20 hours ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-161-20250414 (https://download.01.org/0day-ci/archive/20250414/202504142245.rmvWCoRj-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
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: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202504142245.rmvWCoRj-lkp@intel.com/
smatch warnings:
kernel/trace/ftrace.c:3437 add_next_hash() warn: variable dereferenced before check 'filter_hash' (see line 3436)
vim +/filter_hash +3437 kernel/trace/ftrace.c
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3413
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3414 static int add_next_hash(struct ftrace_hash **filter_hash, struct ftrace_hash **notrace_hash,
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3415 struct ftrace_ops_hash *ops_hash, struct ftrace_ops_hash *subops_hash)
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3416 {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3417 int size_bits;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3418 int ret;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3419
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3420 /* If the subops trace all functions so must the main ops */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3421 if (ftrace_hash_empty(ops_hash->filter_hash) ||
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3422 ftrace_hash_empty(subops_hash->filter_hash)) {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3423 *filter_hash = EMPTY_HASH;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3424 } else {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3425 /*
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3426 * The main ops filter hash is not empty, so its
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3427 * notrace_hash had better be, as the notrace hash
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3428 * is only used for empty main filter hashes.
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3429 */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3430 WARN_ON_ONCE(!ftrace_hash_empty(ops_hash->notrace_hash));
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3431
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3432 size_bits = max(ops_hash->filter_hash->size_bits,
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3433 subops_hash->filter_hash->size_bits);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3434
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3435 /* Copy the subops hash */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 @3436 *filter_hash = alloc_and_copy_ftrace_hash(size_bits, subops_hash->filter_hash);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 @3437 if (!filter_hash)
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3438 return -ENOMEM;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3439 /* Remove any notrace functions from the copy */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3440 remove_hash(*filter_hash, subops_hash->notrace_hash);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3441
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3442 ret = append_hash(filter_hash, ops_hash->filter_hash,
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3443 size_bits);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3444 if (ret < 0) {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3445 free_ftrace_hash(*filter_hash);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3446 return ret;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3447 }
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3448 }
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3449
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3450 /*
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3451 * Only process notrace hashes if the main filter hash is empty
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3452 * (tracing all functions), otherwise the filter hash will just
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3453 * remove the notrace hash functions, and the notrace hash is
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3454 * not needed.
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3455 */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3456 if (ftrace_hash_empty(*filter_hash)) {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3457 /*
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3458 * Intersect the notrace functions. That is, if two
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3459 * subops are not tracing a set of functions, the
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3460 * main ops will only not trace the functions that are
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3461 * in both subops, but has to trace the functions that
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3462 * are only notrace in one of the subops, for the other
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3463 * subops to be able to trace them.
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3464 */
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3465 size_bits = max(ops_hash->notrace_hash->size_bits,
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3466 subops_hash->notrace_hash->size_bits);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3467 *notrace_hash = alloc_ftrace_hash(size_bits);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3468 if (!*notrace_hash)
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3469 return -ENOMEM;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3470
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3471 ret = intersect_hash(notrace_hash, ops_hash->notrace_hash,
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3472 subops_hash->notrace_hash);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3473 if (ret < 0) {
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3474 free_ftrace_hash(*notrace_hash);
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3475 return ret;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3476 }
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3477 }
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3478 return 0;
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3479 }
0ae6b8ce200da0 Steven Rostedt 2025-04-09 3480
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2025-04-14 14:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202504142245.rmvWCoRj-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--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.