[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202109010541.2HLm1TVa-lkp@intel.com>
Date: Wed, 1 Sep 2021 13:27:17 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, Jiri Olsa <jolsa@...nel.org>
Cc: lkp@...el.com, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: [jolsa-perf:ftrace/direct 5/8] kernel/trace/ftrace.c:5150
register_ftrace_direct() error: uninitialized symbol 'entry'.
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
config: x86_64-randconfig-m001-20210831 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
smatch warnings:
kernel/trace/ftrace.c:5150 register_ftrace_direct() error: uninitialized symbol 'entry'.
vim +/entry +5150 kernel/trace/ftrace.c
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5111) int register_ftrace_direct(unsigned long ip, unsigned long addr)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5112) {
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5113) struct ftrace_direct_func *direct;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5114) struct ftrace_func_entry *entry;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5115) struct ftrace_hash *free_hash = NULL;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5116) struct dyn_ftrace *rec;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5117) int ret = -EBUSY;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5118)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5119) mutex_lock(&direct_mutex);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5120)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5121) /* See if there's a direct function at @ip already */
ff205766dbbee0 Alexei Starovoitov 2019-12-08 5122 if (ftrace_find_rec_direct(ip))
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5123) goto out_unlock;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5124)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5125) ret = -ENODEV;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5126) rec = lookup_rec(ip, ip);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5127) if (!rec)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5128) goto out_unlock;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5129)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5130) /*
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5131) * Check if the rec says it has a direct call but we didn't
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5132) * find one earlier?
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5133) */
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5134) if (WARN_ON(rec->flags & FTRACE_FL_DIRECT))
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5135) goto out_unlock;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5136)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5137) /* Make sure the ip points to the exact record */
406acdd32d3e7d Steven Rostedt (VMware 2019-11-15 5138) if (ip != rec->ip) {
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5139) ip = rec->ip;
406acdd32d3e7d Steven Rostedt (VMware 2019-11-15 5140) /* Need to check this ip for a direct. */
ff205766dbbee0 Alexei Starovoitov 2019-12-08 5141 if (ftrace_find_rec_direct(ip))
406acdd32d3e7d Steven Rostedt (VMware 2019-11-15 5142) goto out_unlock;
406acdd32d3e7d Steven Rostedt (VMware 2019-11-15 5143) }
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5144)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5145) ret = -ENOMEM;
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5146) direct = ftrace_find_direct_func(addr);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5147) if (!direct) {
8a141dd7f7060d Alexei Starovoitov 2021-03-16 5148 direct = ftrace_alloc_direct_func(addr);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5149) if (!direct) {
013bf0da047481 Steven Rostedt (VMware 2019-11-08 @5150) kfree(entry);
Delete this kfree. "entry" isn't initialized yet.
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5151) goto out_unlock;
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5152) }
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5153) }
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5154)
b45bdf4de5473d Jiri Olsa 2021-05-18 5155 entry = ftrace_add_rec_direct(ip, addr, &free_hash);
^^^^^^
b45bdf4de5473d Jiri Olsa 2021-05-18 5156 if (!entry)
b45bdf4de5473d Jiri Olsa 2021-05-18 5157 goto out_unlock;
This patch should probably do free direct or something. The error
handling in this function is quite confusing so I'm not exactly sure.
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5158)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5159) ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5160) if (ret)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5161) remove_hash_entry(direct_functions, entry);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5162)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5163) if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) {
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5164) ret = register_ftrace_function(&direct_ops);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5165) if (ret)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5166) ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5167) }
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5168)
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5169) if (ret) {
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5170) kfree(entry);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5171) if (!direct->count) {
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5172) list_del_rcu(&direct->next);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5173) synchronize_rcu_tasks();
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5174) kfree(direct);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5175) if (free_hash)
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5176) free_ftrace_hash(free_hash);
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5177) free_hash = NULL;
a3ad1a7e396890 Steven Rostedt (VMware 2019-11-08 5178) ftrace_direct_func_count--;
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5179) }
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5180) } else {
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5181) direct->count++;
013bf0da047481 Steven Rostedt (VMware 2019-11-08 5182) }
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5183) out_unlock:
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5184) mutex_unlock(&direct_mutex);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5185)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5186) if (free_hash) {
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5187) synchronize_rcu_tasks();
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5188) free_ftrace_hash(free_hash);
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5189) }
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5190)
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5191) return ret;
763e34e74bb7d5 Steven Rostedt (VMware 2019-11-08 5192) }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists