Skip to contentSkip to conversation

ring-buffer: Fix return value check in test_ringbuffer()

GIT PULL Steven Rostedt 1 participant 1 message Apr 6, 2017

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Linus,

Wei Yongjun fixed a long standing bug in the ring buffer startup test. If for some unknown reason, the kthread that is created fails to be created, the return from kthread_create() is an PTR_ERR and not a NULL. The test incorrectly checks for NULL instead of an error.

Please pull the latest trace-v4.11-rc5 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.11-rc5

Tag SHA1: 727df954e9f7ff3ac10b34633ef3109ce7fcded7 Head SHA1: 62277de758b155dc04b78f195a1cb5208c37b2df

Wei Yongjun (1):
ring-buffer: Fix return value check in test_ringbuffer()

----

 kernel/trace/ring_buffer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---------------------------
commit 62277de758b155dc04b78f195a1cb5208c37b2df
Author: Wei Yongjun <[email protected]>
Date:   Fri Jun 17 17:33:59 2016 +0000

ring-buffer: Fix return value check in test_ringbuffer()

In case of error, the function kthread_run() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 6c43e554a ("ring-buffer: Add ring buffer startup selftest")
kernel/trace/ring_buffer.c +4 -4
index 96fc3c043ad6..54e7a90db848 100644
@@ -4826,9 +4826,9 @@ static __init int test_ringbuffer(void)
 		rb_data[cpu].cnt = cpu;
 		rb_threads[cpu] = kthread_create(rb_test, &rb_data[cpu],
 						 "rbtester/%d", cpu);
-		if (WARN_ON(!rb_threads[cpu])) {
+		if (WARN_ON(IS_ERR(rb_threads[cpu]))) {
 			pr_cont("FAILED\n");
-			ret = -1;
+			ret = PTR_ERR(rb_threads[cpu]);
 			goto out_free;
 		}
 
@@ -4838,9 +4838,9 @@ static __init int test_ringbuffer(void)
 
 	/* Now create the rb hammer! */
 	rb_hammer = kthread_run(rb_hammer_test, NULL, "rbhammer");
-	if (WARN_ON(!rb_hammer)) {
+	if (WARN_ON(IS_ERR(rb_hammer))) {
 		pr_cont("FAILED\n");
-		ret = -1;
+		ret = PTR_ERR(rb_hammer);
 		goto out_free;
 	}