dm log writes: fix check of kthread_run() return value
authorVladimir Zapolskiy <vz@mleia.com>
Wed, 9 Mar 2016 23:22:19 +0000 (01:22 +0200)
committerMike Snitzer <snitzer@redhat.com>
Tue, 30 Aug 2016 23:41:43 +0000 (19:41 -0400)
The kthread_run() function returns either a valid task_struct or
ERR_PTR() value, check for NULL is invalid.  This change fixes potential
for oops, e.g. in OOM situation.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
drivers/md/dm-log-writes.c

index ba24f4f37efc672532861e3a1c65d03780b94a1e..49e4d8d4558fb29bc170ccdf9ce07fe56a16a127 100644 (file)
@@ -459,9 +459,9 @@ static int log_writes_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                goto bad;
        }
 
-       ret = -EINVAL;
        lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write");
-       if (!lc->log_kthread) {
+       if (IS_ERR(lc->log_kthread)) {
+               ret = PTR_ERR(lc->log_kthread);
                ti->error = "Couldn't alloc kthread";
                dm_put_device(ti, lc->dev);
                dm_put_device(ti, lc->logdev);