* [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
@ 2021-09-01 17:47 kernel test robot
2021-09-03 10:12 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2021-09-01 17:47 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 20445 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Jiri Olsa <jolsa@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git ftrace/direct
head: 95a037919f1906d8bf164fb0c0066c9f298df139
commit: b45bdf4de5473d5c15090eceeb72a2d5082cde2d [5/8] ftrace: Add ftrace_add_rec_direct function
:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
config: i386-randconfig-c001-20210831 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?id=b45bdf4de5473d5c15090eceeb72a2d5082cde2d
git remote add jolsa-perf https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
git fetch --no-tags jolsa-perf ftrace/direct
git checkout b45bdf4de5473d5c15090eceeb72a2d5082cde2d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
include/linux/irqflags.h:223:3: note: expanded from macro 'local_irq_restore'
raw_local_irq_restore(flags); \
^
include/linux/irqflags.h:174:2: note: expanded from macro 'raw_local_irq_restore'
do { \
^
kernel/trace/ftrace.c:6870:2: note: Loop condition is false. Exiting loop
local_irq_restore(flags);
^
include/linux/irqflags.h:220:2: note: expanded from macro 'local_irq_restore'
do { \
^
kernel/trace/ftrace.c:6871:6: note: Assuming 'ret' is 0
if (ret)
^~~
kernel/trace/ftrace.c:6871:2: note: Taking false branch
if (ret)
^
kernel/trace/ftrace.c:6875:6: note: Assuming 'count' is not equal to 0
if (!count) {
^~~~~~
kernel/trace/ftrace.c:6875:2: note: Taking false branch
if (!count) {
^
kernel/trace/ftrace.c:6892:2: note: Calling 'set_ftrace_early_filters'
set_ftrace_early_filters();
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5616:6: note: Assuming the condition is true
if (ftrace_filter_buf[0])
^~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5616:2: note: Taking true branch
if (ftrace_filter_buf[0])
^
kernel/trace/ftrace.c:5617:3: note: Calling 'ftrace_set_early_filter'
ftrace_set_early_filter(&global_ops, ftrace_filter_buf, 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5608:2: note: Loop condition is true. Entering loop body
while (buf) {
^
kernel/trace/ftrace.c:5610:3: note: Calling 'ftrace_set_regex'
ftrace_set_regex(ops, func, strlen(func), 0, enable);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5451:9: note: Calling 'ftrace_set_hash'
return ftrace_set_hash(ops, buf, len, 0, 0, reset, enable);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:4991:6: note: Assuming 'ftrace_disabled' is 0
if (unlikely(ftrace_disabled))
^
include/linux/compiler.h:48:24: note: expanded from macro 'unlikely'
# define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:33:32: note: expanded from macro '__branch_check__'
______r = __builtin_expect(!!(x), expect); \
^~~~
kernel/trace/ftrace.c:4991:2: note: Taking false branch
if (unlikely(ftrace_disabled))
^
kernel/trace/ftrace.c:4996:6: note: 'enable' is 1
if (enable)
^~~~~~
kernel/trace/ftrace.c:4996:2: note: Taking true branch
if (enable)
^
kernel/trace/ftrace.c:5001:6: note: 'reset' is 0
if (reset)
^~~~~
kernel/trace/ftrace.c:5001:2: note: Taking false branch
if (reset)
^
kernel/trace/ftrace.c:5004:63: note: Passing value via 2nd parameter 'hash'
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
^~~~~~~~~~
kernel/trace/ftrace.c:5004:10: note: Calling 'alloc_and_copy_ftrace_hash'
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:1324:6: note: Assuming 'new_hash' is non-null
if (!new_hash)
^~~~~~~~~
kernel/trace/ftrace.c:1324:2: note: Taking false branch
if (!new_hash)
^
kernel/trace/ftrace.c:1327:6: note: Assuming 'hash' is null
if (hash)
^~~~
kernel/trace/ftrace.c:1327:6: note: Assuming pointer value is null
if (hash)
^~~~
kernel/trace/ftrace.c:1327:2: note: Taking false branch
if (hash)
^
kernel/trace/ftrace.c:1331:6: note: Assuming the condition is false
if (ftrace_hash_empty(hash))
^~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:1331:2: note: Taking false branch
if (ftrace_hash_empty(hash))
^
kernel/trace/ftrace.c:1334:14: note: Access to field 'size_bits' results in a dereference of a null pointer (loaded from variable 'hash')
size = 1 << hash->size_bits;
^~~~
>> kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
kfree(entry);
^ ~~~~~
kernel/trace/ftrace.c:5114:2: note: 'entry' declared without an initial value
struct ftrace_func_entry *entry;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Calling 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:2391:6: note: Assuming 'entry' is null, which participates in a condition later
if (!entry)
^~~~~~
kernel/trace/ftrace.c:2391:2: note: Taking true branch
if (!entry)
^
kernel/trace/ftrace.c:2392:3: note: Returning zero, which participates in a condition later
return 0;
^~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Returning from 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:2: note: Taking false branch
if (ftrace_find_rec_direct(ip))
^
kernel/trace/ftrace.c:5127:6: note: Assuming 'rec' is non-null
if (!rec)
^~~~
kernel/trace/ftrace.c:5127:2: note: Taking false branch
if (!rec)
^
kernel/trace/ftrace.c:5134:6: note: Assuming the condition is true
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:121:23: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~~~~
kernel/trace/ftrace.c:5134:6: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
if (unlikely(__ret_warn_on)) \
^
kernel/trace/ftrace.c:5134:2: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
kernel/trace/ftrace.c:5138:6: note: Assuming 'ip' is equal to field 'ip'
if (ip != rec->ip) {
^~~~~~~~~~~~~
kernel/trace/ftrace.c:5138:2: note: Taking false branch
if (ip != rec->ip) {
^
kernel/trace/ftrace.c:5147:6: note: Assuming 'direct' is null
if (!direct) {
^~~~~~~
kernel/trace/ftrace.c:5147:2: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5148:12: note: Calling 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Calling 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h:579:2: note: Taking false branch
if (__builtin_constant_p(size)) {
^
include/linux/slab.h:596:2: note: Returning pointer, which participates in a condition later
return __kmalloc(size, flags);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Returning from 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5085:6: note: Assuming 'direct' is null, which participates in a condition later
if (!direct)
^~~~~~~
kernel/trace/ftrace.c:5085:2: note: Taking true branch
if (!direct)
^
kernel/trace/ftrace.c:5086:3: note: Returning null pointer, which participates in a condition later
return NULL;
^~~~~~~~~~~
kernel/trace/ftrace.c:5148:12: note: Returning from 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5149:8: note: 'direct' is null
if (!direct) {
^~~~~~
kernel/trace/ftrace.c:5149:3: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5150:4: note: 1st function call argument is an uninitialized value
kfree(entry);
^ ~~~~~
kernel/trace/ftrace.c:6885:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = ftrace_process_locs(NULL,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:6885:2: note: Value stored to 'ret' is never read
ret = ftrace_process_locs(NULL,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 10 warnings (7 in non-user code, 3 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
vim +5150 kernel/trace/ftrace.c
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5093
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5094) /**
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5095) * register_ftrace_direct - Call a custom trampoline directly
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5096) * @ip: The address of the nop at the beginning of a function
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5097) * @addr: The address of the trampoline to call at @ip
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5098) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5099) * This is used to connect a direct call from the nop location (@ip)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5100) * at the start of ftrace traced functions. The location that it calls
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5101) * (@addr) must be able to handle a direct call, and save the parameters
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5102) * of the function being traced, and restore them (or inject new ones
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5103) * if needed), before returning.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5104) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5105) * Returns:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5106) * 0 on success
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5107) * -EBUSY - Another direct function is already attached (there can be only one)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5108) * -ENODEV - @ip does not point to a ftrace nop location (or not supported)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5109) * -ENOMEM - There was an allocation failure.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5110) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5111) int register_ftrace_direct(unsigned long ip, unsigned long addr)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5112) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5113) struct ftrace_direct_func *direct;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5114) struct ftrace_func_entry *entry;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5115) struct ftrace_hash *free_hash = NULL;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5116) struct dyn_ftrace *rec;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5117) int ret = -EBUSY;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5118)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5119) mutex_lock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5120)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5121) /* See if there's a direct function at @ip already */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5122 if (ftrace_find_rec_direct(ip))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5123) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5124)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5125) ret = -ENODEV;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5126) rec = lookup_rec(ip, ip);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5127) if (!rec)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5128) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5129)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5130) /*
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5131) * Check if the rec says it has a direct call but we didn't
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5132) * find one earlier?
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5133) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5134) if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5135) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5136)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5137) /* Make sure the ip points to the exact record */
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5138) if (ip != rec->ip) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5139) ip = rec->ip;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5140) /* Need to check this ip for a direct. */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5141 if (ftrace_find_rec_direct(ip))
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5142) goto out_unlock;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5143) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5144)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5145) ret = -ENOMEM;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5146) direct = ftrace_find_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5147) if (!direct) {
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5148 direct = ftrace_alloc_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5149) if (!direct) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 @5150) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5151) goto out_unlock;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5152) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5153) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5154)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5155 entry = ftrace_add_rec_direct(ip, addr, &free_hash);
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5156 if (!entry)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5157 goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5158)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5159) ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5160) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5161) remove_hash_entry(direct_functions, entry);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5162)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5163) if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5164) ret = register_ftrace_function(&direct_ops);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5165) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5166) ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5167) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5168)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5169) if (ret) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5170) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5171) if (!direct->count) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5172) list_del_rcu(&direct->next);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5173) synchronize_rcu_tasks();
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5174) kfree(direct);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5175) if (free_hash)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5176) free_ftrace_hash(free_hash);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5177) free_hash = NULL;
a3ad1a7e3968900 Steven Rostedt (VMware 2019-11-08 5178) ftrace_direct_func_count--;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5179) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5180) } else {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5181) direct->count++;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5182) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5183) out_unlock:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5184) mutex_unlock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5185)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5186) if (free_hash) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5187) synchronize_rcu_tasks();
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5188) free_ftrace_hash(free_hash);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5189) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5190)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5191) return ret;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5192) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5193) EXPORT_SYMBOL_GPL(register_ftrace_direct);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5194)
:::::: The code at line 5150 was first introduced by commit
:::::: 013bf0da0474816f57739daa006c8564ad7396a3 ftrace: Add ftrace_find_direct_func()
:::::: TO: Steven Rostedt (VMware) <rostedt@goodmis.org>
:::::: CC: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34256 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
2021-09-01 17:47 [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage] kernel test robot
@ 2021-09-03 10:12 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-09-03 10:12 UTC (permalink / raw)
To: Jiri Olsa; +Cc: llvm, kbuild-all, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 14706 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git ftrace/direct
head: 95a037919f1906d8bf164fb0c0066c9f298df139
commit: b45bdf4de5473d5c15090eceeb72a2d5082cde2d [5/8] ftrace: Add ftrace_add_rec_direct function
:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
config: i386-randconfig-c001-20210831 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?id=b45bdf4de5473d5c15090eceeb72a2d5082cde2d
git remote add jolsa-perf https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
git fetch --no-tags jolsa-perf ftrace/direct
git checkout b45bdf4de5473d5c15090eceeb72a2d5082cde2d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
kfree(entry);
^ ~~~~~
kernel/trace/ftrace.c:5114:2: note: 'entry' declared without an initial value
struct ftrace_func_entry *entry;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Calling 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:2391:6: note: Assuming 'entry' is null, which participates in a condition later
if (!entry)
^~~~~~
kernel/trace/ftrace.c:2391:2: note: Taking true branch
if (!entry)
^
kernel/trace/ftrace.c:2392:3: note: Returning zero, which participates in a condition later
return 0;
^~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Returning from 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:2: note: Taking false branch
if (ftrace_find_rec_direct(ip))
^
kernel/trace/ftrace.c:5127:6: note: Assuming 'rec' is non-null
if (!rec)
^~~~
kernel/trace/ftrace.c:5127:2: note: Taking false branch
if (!rec)
^
kernel/trace/ftrace.c:5134:6: note: Assuming the condition is true
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:121:23: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~~~~
kernel/trace/ftrace.c:5134:6: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
if (unlikely(__ret_warn_on)) \
^
kernel/trace/ftrace.c:5134:2: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
kernel/trace/ftrace.c:5138:6: note: Assuming 'ip' is equal to field 'ip'
if (ip != rec->ip) {
^~~~~~~~~~~~~
kernel/trace/ftrace.c:5138:2: note: Taking false branch
if (ip != rec->ip) {
^
kernel/trace/ftrace.c:5147:6: note: Assuming 'direct' is null
if (!direct) {
^~~~~~~
kernel/trace/ftrace.c:5147:2: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5148:12: note: Calling 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Calling 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h:579:2: note: Taking false branch
if (__builtin_constant_p(size)) {
^
include/linux/slab.h:596:2: note: Returning pointer, which participates in a condition later
return __kmalloc(size, flags);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Returning from 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5085:6: note: Assuming 'direct' is null, which participates in a condition later
if (!direct)
^~~~~~~
kernel/trace/ftrace.c:5085:2: note: Taking true branch
if (!direct)
^
kernel/trace/ftrace.c:5086:3: note: Returning null pointer, which participates in a condition later
return NULL;
^~~~~~~~~~~
kernel/trace/ftrace.c:5148:12: note: Returning from 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5149:8: note: 'direct' is null
if (!direct) {
^~~~~~
kernel/trace/ftrace.c:5149:3: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5150:4: note: 1st function call argument is an uninitialized value
kfree(entry);
^ ~~~~~
vim +5150 kernel/trace/ftrace.c
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5093
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5094) /**
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5095) * register_ftrace_direct - Call a custom trampoline directly
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5096) * @ip: The address of the nop at the beginning of a function
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5097) * @addr: The address of the trampoline to call at @ip
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5098) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5099) * This is used to connect a direct call from the nop location (@ip)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5100) * at the start of ftrace traced functions. The location that it calls
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5101) * (@addr) must be able to handle a direct call, and save the parameters
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5102) * of the function being traced, and restore them (or inject new ones
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5103) * if needed), before returning.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5104) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5105) * Returns:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5106) * 0 on success
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5107) * -EBUSY - Another direct function is already attached (there can be only one)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5108) * -ENODEV - @ip does not point to a ftrace nop location (or not supported)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5109) * -ENOMEM - There was an allocation failure.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5110) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5111) int register_ftrace_direct(unsigned long ip, unsigned long addr)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5112) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5113) struct ftrace_direct_func *direct;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5114) struct ftrace_func_entry *entry;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5115) struct ftrace_hash *free_hash = NULL;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5116) struct dyn_ftrace *rec;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5117) int ret = -EBUSY;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5118)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5119) mutex_lock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5120)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5121) /* See if there's a direct function at @ip already */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5122 if (ftrace_find_rec_direct(ip))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5123) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5124)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5125) ret = -ENODEV;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5126) rec = lookup_rec(ip, ip);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5127) if (!rec)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5128) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5129)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5130) /*
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5131) * Check if the rec says it has a direct call but we didn't
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5132) * find one earlier?
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5133) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5134) if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5135) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5136)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5137) /* Make sure the ip points to the exact record */
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5138) if (ip != rec->ip) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5139) ip = rec->ip;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5140) /* Need to check this ip for a direct. */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5141 if (ftrace_find_rec_direct(ip))
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5142) goto out_unlock;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5143) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5144)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5145) ret = -ENOMEM;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5146) direct = ftrace_find_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5147) if (!direct) {
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5148 direct = ftrace_alloc_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5149) if (!direct) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 @5150) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5151) goto out_unlock;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5152) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5153) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5154)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5155 entry = ftrace_add_rec_direct(ip, addr, &free_hash);
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5156 if (!entry)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5157 goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5158)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5159) ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5160) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5161) remove_hash_entry(direct_functions, entry);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5162)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5163) if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5164) ret = register_ftrace_function(&direct_ops);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5165) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5166) ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5167) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5168)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5169) if (ret) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5170) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5171) if (!direct->count) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5172) list_del_rcu(&direct->next);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5173) synchronize_rcu_tasks();
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5174) kfree(direct);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5175) if (free_hash)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5176) free_ftrace_hash(free_hash);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5177) free_hash = NULL;
a3ad1a7e3968900 Steven Rostedt (VMware 2019-11-08 5178) ftrace_direct_func_count--;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5179) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5180) } else {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5181) direct->count++;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5182) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5183) out_unlock:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5184) mutex_unlock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5185)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5186) if (free_hash) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5187) synchronize_rcu_tasks();
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5188) free_ftrace_hash(free_hash);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5189) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5190)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5191) return ret;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5192) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5193) EXPORT_SYMBOL_GPL(register_ftrace_direct);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5194)
:::::: The code at line 5150 was first introduced by commit
:::::: 013bf0da0474816f57739daa006c8564ad7396a3 ftrace: Add ftrace_find_direct_func()
:::::: TO: Steven Rostedt (VMware) <rostedt@goodmis.org>
:::::: CC: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34256 bytes --]
[-- Attachment #3: Attached Message Part --]
[-- Type: text/plain, Size: 154 bytes --]
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
@ 2021-09-03 10:12 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-09-03 10:12 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 14941 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git ftrace/direct
head: 95a037919f1906d8bf164fb0c0066c9f298df139
commit: b45bdf4de5473d5c15090eceeb72a2d5082cde2d [5/8] ftrace: Add ftrace_add_rec_direct function
:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
config: i386-randconfig-c001-20210831 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?id=b45bdf4de5473d5c15090eceeb72a2d5082cde2d
git remote add jolsa-perf https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
git fetch --no-tags jolsa-perf ftrace/direct
git checkout b45bdf4de5473d5c15090eceeb72a2d5082cde2d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
kfree(entry);
^ ~~~~~
kernel/trace/ftrace.c:5114:2: note: 'entry' declared without an initial value
struct ftrace_func_entry *entry;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Calling 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:2391:6: note: Assuming 'entry' is null, which participates in a condition later
if (!entry)
^~~~~~
kernel/trace/ftrace.c:2391:2: note: Taking true branch
if (!entry)
^
kernel/trace/ftrace.c:2392:3: note: Returning zero, which participates in a condition later
return 0;
^~~~~~~~
kernel/trace/ftrace.c:5122:6: note: Returning from 'ftrace_find_rec_direct'
if (ftrace_find_rec_direct(ip))
^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5122:2: note: Taking false branch
if (ftrace_find_rec_direct(ip))
^
kernel/trace/ftrace.c:5127:6: note: Assuming 'rec' is non-null
if (!rec)
^~~~
kernel/trace/ftrace.c:5127:2: note: Taking false branch
if (!rec)
^
kernel/trace/ftrace.c:5134:6: note: Assuming the condition is true
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:121:23: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~~~~
kernel/trace/ftrace.c:5134:6: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
if (unlikely(__ret_warn_on)) \
^
kernel/trace/ftrace.c:5134:2: note: Taking false branch
if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
^
kernel/trace/ftrace.c:5138:6: note: Assuming 'ip' is equal to field 'ip'
if (ip != rec->ip) {
^~~~~~~~~~~~~
kernel/trace/ftrace.c:5138:2: note: Taking false branch
if (ip != rec->ip) {
^
kernel/trace/ftrace.c:5147:6: note: Assuming 'direct' is null
if (!direct) {
^~~~~~~
kernel/trace/ftrace.c:5147:2: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5148:12: note: Calling 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Calling 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/slab.h:579:2: note: Taking false branch
if (__builtin_constant_p(size)) {
^
include/linux/slab.h:596:2: note: Returning pointer, which participates in a condition later
return __kmalloc(size, flags);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5084:11: note: Returning from 'kmalloc'
direct = kmalloc(sizeof(*direct), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5085:6: note: Assuming 'direct' is null, which participates in a condition later
if (!direct)
^~~~~~~
kernel/trace/ftrace.c:5085:2: note: Taking true branch
if (!direct)
^
kernel/trace/ftrace.c:5086:3: note: Returning null pointer, which participates in a condition later
return NULL;
^~~~~~~~~~~
kernel/trace/ftrace.c:5148:12: note: Returning from 'ftrace_alloc_direct_func'
direct = ftrace_alloc_direct_func(addr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:5149:8: note: 'direct' is null
if (!direct) {
^~~~~~
kernel/trace/ftrace.c:5149:3: note: Taking true branch
if (!direct) {
^
kernel/trace/ftrace.c:5150:4: note: 1st function call argument is an uninitialized value
kfree(entry);
^ ~~~~~
vim +5150 kernel/trace/ftrace.c
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5093
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5094) /**
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5095) * register_ftrace_direct - Call a custom trampoline directly
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5096) * @ip: The address of the nop at the beginning of a function
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5097) * @addr: The address of the trampoline to call at @ip
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5098) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5099) * This is used to connect a direct call from the nop location (@ip)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5100) * at the start of ftrace traced functions. The location that it calls
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5101) * (@addr) must be able to handle a direct call, and save the parameters
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5102) * of the function being traced, and restore them (or inject new ones
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5103) * if needed), before returning.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5104) *
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5105) * Returns:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5106) * 0 on success
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5107) * -EBUSY - Another direct function is already attached (there can be only one)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5108) * -ENODEV - @ip does not point to a ftrace nop location (or not supported)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5109) * -ENOMEM - There was an allocation failure.
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5110) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5111) int register_ftrace_direct(unsigned long ip, unsigned long addr)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5112) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5113) struct ftrace_direct_func *direct;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5114) struct ftrace_func_entry *entry;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5115) struct ftrace_hash *free_hash = NULL;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5116) struct dyn_ftrace *rec;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5117) int ret = -EBUSY;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5118)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5119) mutex_lock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5120)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5121) /* See if there's a direct function at @ip already */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5122 if (ftrace_find_rec_direct(ip))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5123) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5124)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5125) ret = -ENODEV;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5126) rec = lookup_rec(ip, ip);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5127) if (!rec)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5128) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5129)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5130) /*
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5131) * Check if the rec says it has a direct call but we didn't
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5132) * find one earlier?
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5133) */
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5134) if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5135) goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5136)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5137) /* Make sure the ip points to the exact record */
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5138) if (ip != rec->ip) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5139) ip = rec->ip;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5140) /* Need to check this ip for a direct. */
ff205766dbbee02 Alexei Starovoitov 2019-12-08 5141 if (ftrace_find_rec_direct(ip))
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5142) goto out_unlock;
406acdd32d3e7d5 Steven Rostedt (VMware 2019-11-15 5143) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5144)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5145) ret = -ENOMEM;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5146) direct = ftrace_find_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5147) if (!direct) {
8a141dd7f7060d1 Alexei Starovoitov 2021-03-16 5148 direct = ftrace_alloc_direct_func(addr);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5149) if (!direct) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 @5150) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5151) goto out_unlock;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5152) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5153) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5154)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5155 entry = ftrace_add_rec_direct(ip, addr, &free_hash);
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5156 if (!entry)
b45bdf4de5473d5 Jiri Olsa 2021-05-18 5157 goto out_unlock;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5158)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5159) ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5160) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5161) remove_hash_entry(direct_functions, entry);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5162)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5163) if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5164) ret = register_ftrace_function(&direct_ops);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5165) if (ret)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5166) ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5167) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5168)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5169) if (ret) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5170) kfree(entry);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5171) if (!direct->count) {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5172) list_del_rcu(&direct->next);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5173) synchronize_rcu_tasks();
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5174) kfree(direct);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5175) if (free_hash)
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5176) free_ftrace_hash(free_hash);
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5177) free_hash = NULL;
a3ad1a7e3968900 Steven Rostedt (VMware 2019-11-08 5178) ftrace_direct_func_count--;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5179) }
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5180) } else {
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5181) direct->count++;
013bf0da0474816 Steven Rostedt (VMware 2019-11-08 5182) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5183) out_unlock:
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5184) mutex_unlock(&direct_mutex);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5185)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5186) if (free_hash) {
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5187) synchronize_rcu_tasks();
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5188) free_ftrace_hash(free_hash);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5189) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5190)
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5191) return ret;
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5192) }
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5193) EXPORT_SYMBOL_GPL(register_ftrace_direct);
763e34e74bb7d5c Steven Rostedt (VMware 2019-11-08 5194)
:::::: The code at line 5150 was first introduced by commit
:::::: 013bf0da0474816f57739daa006c8564ad7396a3 ftrace: Add ftrace_find_direct_func()
:::::: TO: Steven Rostedt (VMware) <rostedt@goodmis.org>
:::::: CC: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34256 bytes --]
[-- Attachment #3: AttachedMessagePart.ksh --]
[-- Type: text/plain, Size: 154 bytes --]
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-03 10:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 17:47 [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150:4: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage] kernel test robot
2021-09-03 10:12 ` kernel test robot
2021-09-03 10:12 ` kernel test robot
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.