linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Minfei Huang <mnghuan@gmail.com>
To: agk@redhat.com, snitzer@redhat.com, shli@kernel.org
Cc: dm-devel@redhat.com, linux-raid@vger.kernel.org,
	linux-kernel@vger.kernel.org, Minfei Huang <mnghuan@gmail.com>
Subject: [PATCH RESENT] dm: Check kthread_run's return value
Date: Mon,  4 Jul 2016 23:25:27 +0800	[thread overview]
Message-ID: <1467645927-4143-1-git-send-email-mnghuan@gmail.com> (raw)

kthread function is used to process kthread_work. And there is no return
value checking during create this thread. Add this checking to fix this
issue.

Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
 drivers/md/dm.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1b2f962..d68b9d2 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2654,12 +2654,15 @@ struct queue_limits *dm_get_queue_limits(struct mapped_device *md)
 }
 EXPORT_SYMBOL_GPL(dm_get_queue_limits);
 
-static void dm_old_init_rq_based_worker_thread(struct mapped_device *md)
+static int dm_old_init_rq_based_worker_thread(struct mapped_device *md)
 {
 	/* Initialize the request-based DM worker thread */
 	init_kthread_worker(&md->kworker);
 	md->kworker_task = kthread_run(kthread_worker_fn, &md->kworker,
 				       "kdmwork-%s", dm_device_name(md));
+	if (IS_ERR(md->kworker_task))
+		return -ENOMEM;
+	return 0;
 }
 
 /*
@@ -2667,6 +2670,8 @@ static void dm_old_init_rq_based_worker_thread(struct mapped_device *md)
  */
 static int dm_old_init_request_queue(struct mapped_device *md)
 {
+	int ret;
+
 	/* Fully initialize the queue */
 	if (!blk_init_allocated_queue(md->queue, dm_request_fn, NULL))
 		return -EINVAL;
@@ -2678,7 +2683,9 @@ static int dm_old_init_request_queue(struct mapped_device *md)
 	blk_queue_softirq_done(md->queue, dm_softirq_done);
 	blk_queue_prep_rq(md->queue, dm_old_prep_fn);
 
-	dm_old_init_rq_based_worker_thread(md);
+	ret = dm_old_init_rq_based_worker_thread(md);
+	if (ret < 0)
+		return ret;
 
 	elv_register_queue(md->queue);
 
-- 
2.6.3

             reply	other threads:[~2016-07-04 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 15:25 Minfei Huang [this message]
2016-07-06 13:16 ` [PATCH RESENT] dm: Check kthread_run's return value Mike Snitzer
2016-07-06 13:27   ` Minfei Huang
2016-07-06 13:31     ` Mike Snitzer
2016-07-06 13:38       ` Minfei Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467645927-4143-1-git-send-email-mnghuan@gmail.com \
    --to=mnghuan@gmail.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@kernel.org \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).