public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Aota <naota@elisp.net>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Jiri Kosina <jkosina@suse.cz>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Naohiro Aota <naota@elisp.net>, Daniel Mack <daniel@caiaq.de>,
	linux-scsi@vger.kernel.org
Subject: [PATCH] bsg: call idr_pre_get() outside the lock.
Date: Wed, 01 Sep 2010 23:26:01 +0900	[thread overview]
Message-ID: <m2eidda6bq.fsf@elisp.net> (raw)

The idr_pre_get() kernel-doc says "This function should be called
prior to locking and calling the idr_get_new* functions.", but the
idr_pre_get() calling in bsg_register_queue() is put inside
mutex_lock(). Let's fix it.

Signed-off-by: Naohiro Aota <naota@elisp.net>
---
 block/bsg.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 82d5882..5fd8dd1 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -1010,13 +1010,11 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
 	bcd = &q->bsg_dev;
 	memset(bcd, 0, sizeof(*bcd));
 
-	mutex_lock(&bsg_mutex);
-
 	ret = idr_pre_get(&bsg_minor_idr, GFP_KERNEL);
-	if (!ret) {
-		ret = -ENOMEM;
-		goto unlock;
-	}
+	if (!ret)
+		return -ENOMEM;
+
+	mutex_lock(&bsg_mutex);
 
 	ret = idr_get_new(&bsg_minor_idr, bcd, &minor);
 	if (ret < 0)
-- 
1.7.2


             reply	other threads:[~2010-09-01 14:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-01 14:26 Naohiro Aota [this message]
2010-09-02  4:13 ` [PATCH] bsg: call idr_pre_get() outside the lock FUJITA Tomonori
2010-09-16 23:37 ` Andrew Morton
2010-09-17  2:55   ` James Bottomley
2010-09-18  3:40   ` FUJITA Tomonori
2010-09-19  3:11   ` Naohiro Aota

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=m2eidda6bq.fsf@elisp.net \
    --to=naota@elisp.net \
    --cc=axboe@kernel.dk \
    --cc=daniel@caiaq.de \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=gregkh@suse.de \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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