Re: [PATCH] tracing: Fix crash passing ERR_PTR to kthread_stop()

Steven Rostedt <[email protected]>
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-trace-kernel
Message-ID <20260816191508.27f87c31@robin>
On Sat, 15 Aug 2026 19:10:34 +0000
[email protected] wrote:

> > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> > index 0356cae0cf74e..207f47f54dbbf 100644
> > --- a/kernel/trace/trace_events.c
> > +++ b/kernel/trace/trace_events.c
> > @@ -3866,6 +3866,8 @@ static __init void event_test_stuff(void)
> >  	struct task_struct *test_thread;
> >  
> >  	test_thread = kthread_run(event_test_thread, NULL, "test-events");
> > +	if (IS_ERR(test_thread))
> > +		return;  
> 
> [Severity: Medium]
> Does returning silently here cause the self-test framework to falsely report
> success when the workload thread cannot be created?
> 
> The caller event_trace_self_tests() unconditionally prints "OK" after calling
> this function:
> 
> kernel/trace/trace_events.c:event_trace_self_tests() {
>         ...
> 		ftrace_event_enable_disable(file, 1);
> 		event_test_stuff();
> 		ftrace_event_enable_disable(file, 0);
> 
> 		pr_cont("OK\n");
> 	}
>         ...
> }
> 
> Should event_test_stuff() propagate the error so that the caller can correctly
> report the test failure or skip it appropriately?

Right, this is just a boot up test that is only done for debugging.
This is not something for production. If it fails, it should not fail
silently. If anything, it should be:

	if (WARN_ON(IS_ERR(test_thread))
		return;

-- Steve
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.