]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.60/tracing-quiet-gcc-warning-about-maybe-unused-link-variable.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / tracing-quiet-gcc-warning-about-maybe-unused-link-variable.patch
1 From 2519c1bbe38d7acacc9aacba303ca6f97482ed53 Mon Sep 17 00:00:00 2001
2 From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
3 Date: Wed, 25 Jul 2018 22:28:56 -0400
4 Subject: tracing: Quiet gcc warning about maybe unused link variable
5
6 From: Steven Rostedt (VMware) <rostedt@goodmis.org>
7
8 commit 2519c1bbe38d7acacc9aacba303ca6f97482ed53 upstream.
9
10 Commit 57ea2a34adf4 ("tracing/kprobes: Fix trace_probe flags on
11 enable_trace_kprobe() failure") added an if statement that depends on another
12 if statement that gcc doesn't see will initialize the "link" variable and
13 gives the warning:
14
15 "warning: 'link' may be used uninitialized in this function"
16
17 It is really a false positive, but to quiet the warning, and also to make
18 sure that it never actually is used uninitialized, initialize the "link"
19 variable to NULL and add an if (!WARN_ON_ONCE(!link)) where the compiler
20 thinks it could be used uninitialized.
21
22 Cc: stable@vger.kernel.org
23 Fixes: 57ea2a34adf4 ("tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure")
24 Reported-by: kbuild test robot <lkp@intel.com>
25 Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 kernel/trace/trace_kprobe.c | 6 ++++--
30 1 file changed, 4 insertions(+), 2 deletions(-)
31
32 --- a/kernel/trace/trace_kprobe.c
33 +++ b/kernel/trace/trace_kprobe.c
34 @@ -376,7 +376,7 @@ static struct trace_kprobe *find_trace_k
35 static int
36 enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
37 {
38 - struct event_file_link *link;
39 + struct event_file_link *link = NULL;
40 int ret = 0;
41
42 if (file) {
43 @@ -402,7 +402,9 @@ enable_trace_kprobe(struct trace_kprobe
44
45 if (ret) {
46 if (file) {
47 - list_del_rcu(&link->list);
48 + /* Notice the if is true on not WARN() */
49 + if (!WARN_ON_ONCE(!link))
50 + list_del_rcu(&link->list);
51 kfree(link);
52 tk->tp.flags &= ~TP_FLAG_TRACE;
53 } else {