From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755330Ab0IAO0Q (ORCPT ); Wed, 1 Sep 2010 10:26:16 -0400 Received: from s318.xrea.com ([125.53.25.46]:57837 "HELO s318.xrea.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754436Ab0IAO0O (ORCPT ); Wed, 1 Sep 2010 10:26:14 -0400 From: Naohiro Aota To: FUJITA Tomonori Cc: linux-kernel@vger.kernel.org, Jens Axboe , Jiri Kosina , Greg Kroah-Hartman , Naohiro Aota , Daniel Mack , linux-scsi@vger.kernel.org Subject: [PATCH] bsg: call idr_pre_get() outside the lock. Date: Wed, 01 Sep 2010 23:26:01 +0900 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (darwin) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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