tracepoint: Do not warn on ENOMEM
authorMathieu Desnoyers <[email protected]>
Thu, 15 Mar 2018 12:44:24 +0000 (08:44 -0400)
committerSteven Rostedt (VMware) <[email protected]>
Mon, 30 Apr 2018 16:09:56 +0000 (12:09 -0400)
Tracepoint should only warn when a kernel API user does not respect the
required preconditions (e.g. same tracepoint enabled twice, or called
to remove a tracepoint that does not exist).

Silence warning in out-of-memory conditions, given that the error is
returned to the caller.

This ensures that out-of-memory error-injection testing does not trigger
warnings in tracepoint.c, which were seen by syzbot.

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
CC: Peter Zijlstra <[email protected]>
CC: Jiri Olsa <[email protected]>
CC: Arnaldo Carvalho de Melo <[email protected]>
CC: Alexander Shishkin <[email protected]>
CC: Namhyung Kim <[email protected]>
CC: [email protected]
Fixes: de7b2973903c6 ("tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints")
Reported-by: [email protected]
Reported-by: [email protected]
Signed-off-by: Mathieu Desnoyers <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
kernel/tracepoint.c

index 671b134573876d7ab5f8c3b2f1b8722b909c1201..1e37da2e0c25d13ec7e6bd79be165a38f58b4fb3 100644 (file)
@@ -207,7 +207,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
                        lockdep_is_held(&tracepoints_mutex));
        old = func_add(&tp_funcs, func, prio);
        if (IS_ERR(old)) {
-               WARN_ON_ONCE(1);
+               WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
                return PTR_ERR(old);
        }
 
@@ -239,7 +239,7 @@ static int tracepoint_remove_func(struct tracepoint *tp,
                        lockdep_is_held(&tracepoints_mutex));
        old = func_remove(&tp_funcs, func);
        if (IS_ERR(old)) {
-               WARN_ON_ONCE(1);
+               WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
                return PTR_ERR(old);
        }