Skip to contentSkip to conversation

Fix: tracepoint: do not warn on ENOMEM

PATCH New Mathieu Desnoyers 1 participant 1 message Mar 15, 2018

Subsystems (2)
lore
Share & tools
lore

Mathieu Desnoyers

author reviewer
#0 lore raw

PATCH 1/1 Fix: tracepoint: do not warn on ENOMEM

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.

---
 kernel/tracepoint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/tracepoint.c +2 -2
index 671b13457387..1e37da2e0c25 100644
@@ -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);
 	}
 
Signature · 1 line
2.11.0