Commit dab04fda authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Greg Kroah-Hartman

tracing: Quiet gcc warning about maybe unused link variable

commit 2519c1bb upstream.

Commit 57ea2a34 ("tracing/kprobes: Fix trace_probe flags on
enable_trace_kprobe() failure") added an if statement that depends on another
if statement that gcc doesn't see will initialize the "link" variable and
gives the warning:

 "warning: 'link' may be used uninitialized in this function"

It is really a false positive, but to quiet the warning, and also to make
sure that it never actually is used uninitialized, initialize the "link"
variable to NULL and add an if (!WARN_ON_ONCE(!link)) where the compiler
thinks it could be used uninitialized.

Cc: stable@vger.kernel.org
Fixes: 57ea2a34 ("tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure")
Reported-by: default avatarkbuild test robot <lkp@intel.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d9bbd807
...@@ -349,7 +349,7 @@ static struct trace_kprobe *find_trace_kprobe(const char *event, ...@@ -349,7 +349,7 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
static int static int
enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
{ {
struct event_file_link *link; struct event_file_link *link = NULL;
int ret = 0; int ret = 0;
if (file) { if (file) {
...@@ -375,6 +375,8 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) ...@@ -375,6 +375,8 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
if (ret) { if (ret) {
if (file) { if (file) {
/* Notice the if is true on not WARN() */
if (!WARN_ON_ONCE(!link))
list_del_rcu(&link->list); list_del_rcu(&link->list);
kfree(link); kfree(link);
tk->tp.flags &= ~TP_FLAG_TRACE; tk->tp.flags &= ~TP_FLAG_TRACE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment