greybus: es2: test apb1_log_task safely

When usb_log_enable() is called, the global apb1_log_task is used to
hold the result of kthread_run().  It is possible for kthread_run()
to return an error pointer, so tests of apb_log_task against NULL
are insufficient to determine its validity.

Note that kthread_run() never returns NULL so we don't have to check
for that.  But apb1_log_task is initially NULL, so that global must
be both non-null and not an error in order to be considered valid.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index e463750..23e2778 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -540,12 +540,12 @@
 
 static void usb_log_enable(struct es1_ap_dev *es1)
 {
-	if (apb1_log_task != NULL)
+	if (!IS_ERR_OR_NULL(apb1_log_task))
 		return;
 
 	/* get log from APB1 */
 	apb1_log_task = kthread_run(apb1_log_poll, es1, "apb1_log");
-	if (apb1_log_task == ERR_PTR(-ENOMEM))
+	if (IS_ERR(apb1_log_task))
 		return;
 	apb1_log_dentry = debugfs_create_file("apb1_log", S_IRUGO,
 						gb_debugfs_get(), NULL,
@@ -554,7 +554,7 @@
 
 static void usb_log_disable(struct es1_ap_dev *es1)
 {
-	if (apb1_log_task == NULL)
+	if (IS_ERR_OR_NULL(apb1_log_task))
 		return;
 
 	debugfs_remove(apb1_log_dentry);
@@ -568,7 +568,7 @@
 				size_t count, loff_t *ppos)
 {
 	char tmp_buf[3];
-	int enable = apb1_log_task != NULL;
+	int enable = !IS_ERR_OR_NULL(apb1_log_task);
 
 	sprintf(tmp_buf, "%d\n", enable);
 	return simple_read_from_buffer(buf, count, ppos, tmp_buf, 3);