Skip to contentSkip to conversation

tracing/events: add startup tests for events

bug report Dan Carpenter 2 participants 2 messages Aug 7, 2025 – Aug 13, 2025 Tracing

lore
Share & tools
lore
#0 lore raw

Hello Steven Rostedt,

Commit e6187007d6c3 ("tracing/events: add startup tests for events") from Apr 15, 2009 (linux-next), leads to the following Smatch static checker warning:

	kernel/trace/trace_events.c:4704 event_test_stuff()
	error: 'test_thread' dereferencing possible ERR_PTR()

kernel/trace/trace_events.c

    4698 static __init void event_test_stuff(void)
    4699 {
    4700         struct task_struct *test_thread;
    4701 
    4702         test_thread = kthread_run(event_test_thread, NULL, "test-events");
    4703         msleep(1);

--> 4704 kthread_stop(test_thread);

Check for if (!IS_ERR(test_thread)) ?

    4705 }

regards,
dan carpenter

maintainer
#1 lore raw
Quoted 5 lines · On Thu, 7 Aug 2025 18:52:56 +0300 Dan Carpenter <[email protected]>…

Hello Steven Rostedt,

Commit e6187007d6c3 ("tracing/events: add startup tests for events") from Apr 15, 2009 (linux-next), leads to the following Smatch static checker warning:

So this "bug" is in a selftest that has been running fine since 2009.

Yes, if things go really bad then kthread_run() could return an error, and if it does, it means the system is having major issues at boot up.

Quoted 11 lines
	kernel/trace/trace_events.c:4704 event_test_stuff()
	error: 'test_thread' dereferencing possible ERR_PTR()

kernel/trace/trace_events.c

    4698 static __init void event_test_stuff(void)
    4699 {
    4700         struct task_struct *test_thread;
    4701 
    4702         test_thread = kthread_run(event_test_thread, NULL, "test-events");
    4703         msleep(1);
Quoted 3 lines

--> 4704 kthread_stop(test_thread);

Check for if (!IS_ERR(test_thread)) ?

I'm not against taking a patch that adds a check, but I don't plan on updating it myself.

static __init void event_test_stuff(void)

{
	struct task_struct *test_thread;

	test_thread = kthread_run(event_test_thread, NULL, "test-events");
	if (WARN_ON_ONCE(IS_ERR(test_thread)))
		return;
	msleep(1);
	kthread_stop(test_thread);
}

Would work for me.

-- Steve

Quoted 5 lines
    4705 }

regards,
dan carpenter