NTB: Fix incorrect return check in ntb_perf
authorDave Jiang <dave.jiang@intel.com>
Fri, 18 Mar 2016 23:39:41 +0000 (16:39 -0700)
committerJon Mason <jdmason@kudzu.us>
Mon, 21 Mar 2016 23:28:25 +0000 (19:28 -0400)
kthread_create_no_node() returns error pointers, never NULL. Fix check so
it handles error correctly.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/test/ntb_perf.c

index cf19ff07680dba12fbfe4935fd68869c44a671e8..d82d10791e7d5544c4f3ccb161b825b213590ae8 100644 (file)
@@ -615,9 +615,7 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
                                kthread_create_on_node(ntb_perf_thread,
                                                       (void *)pctx,
                                                       node, "ntb_perf %d", i);
-                       if (pctx->thread)
-                               wake_up_process(pctx->thread);
-                       else {
+                       if (IS_ERR(pctx->thread)) {
                                perf->run = false;
                                for (i = 0; i < MAX_THREADS; i++) {
                                        if (pctx->thread) {
@@ -625,7 +623,8 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
                                                pctx->thread = NULL;
                                        }
                                }
-                       }
+                       } else
+                               wake_up_process(pctx->thread);
 
                        if (perf->run == false)
                                return -ENXIO;