linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bsg: call idr_pre_get() outside the lock.
@ 2010-09-01 14:26 Naohiro Aota
  2010-09-02  4:13 ` FUJITA Tomonori
  2010-09-16 23:37 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Naohiro Aota @ 2010-09-01 14:26 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: linux-kernel, Jens Axboe, Jiri Kosina, Greg Kroah-Hartman,
	Naohiro Aota, Daniel Mack, linux-scsi

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-19  3:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-01 14:26 [PATCH] bsg: call idr_pre_get() outside the lock Naohiro Aota
2010-09-02  4:13 ` 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

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).