[PATCH 15/61] trace: Prefer IS_ERR_OR_NULL over manual NULL check

Philipp Hahn
2026-03-10T12:01:33Z

Prefer using IS_ERR_OR_NULL() over using IS_ERR() and a manual NULL
check.

Change generated with coccinelle.

To: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-trace-kernel@vger.kernel.org
Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
kernel/trace/fprobe.c | 2 +-
kernel/trace/kprobe_event_gen_test.c | 2 +-
kernel/trace/trace_events_hist.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index dcadf1d23b8a31f571392d0c49cbd22df1716b4f..a94ce810d83b90f55d1178a9bd29c78fd068df4c 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -607,7 +607,7 @@ static int fprobe_module_callback(struct notifier_block *nb,
do {
rhashtable_walk_start(&iter);

- while ((node = rhashtable_walk_next(&iter)) && !IS_ERR(node))
+ while (!IS_ERR_OR_NULL((node = rhashtable_walk_next(&iter))))
fprobe_remove_node_in_module(mod, node, &alist);

rhashtable_walk_stop(&iter);
diff --git a/kernel/trace/kprobe_event_gen_test.c b/kernel/trace/kprobe_event_gen_test.c
index 5a4b722b50451bfdee42769a6d3be39c055690d1..a1735ca273f0b756aa1fcfcdab30ddad9bc51c5f 100644
--- a/kernel/trace/kprobe_event_gen_test.c
+++ b/kernel/trace/kprobe_event_gen_test.c
@@ -75,7 +75,7 @@ static struct trace_event_file *gen_kretprobe_test;

static bool trace_event_file_is_valid(struct trace_event_file *input)
{
- return input && !IS_ERR(input);
+ return !IS_ERR_OR_NULL(input);
}

/*
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 73ea180cad555898693e92ee397a1c9493c7c167..59df215e1dfd9349eca1c0823ed709ec7285f766 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -3973,7 +3973,7 @@ trace_action_create_field_var(struct hist_trigger_data *hist_data,
*/
field_var = create_target_field_var(hist_data, system, event, var);

- if (field_var && !IS_ERR(field_var)) {
+ if (!IS_ERR_OR_NULL(field_var)) {
save_field_var(hist_data, field_var);
hist_field = field_var->var;
} else {

--
2.43.0