From patchwork Fri Jan 29 21:45:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chiang X-Patchwork-Id: 75848 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o0TLlbkv003022 for ; Fri, 29 Jan 2010 21:47:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755511Ab0A2Vqc (ORCPT ); Fri, 29 Jan 2010 16:46:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754640Ab0A2VpZ (ORCPT ); Fri, 29 Jan 2010 16:45:25 -0500 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:8342 "EHLO g5t0006.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754424Ab0A2VpU (ORCPT ); Fri, 29 Jan 2010 16:45:20 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id 71BBAC39A; Fri, 29 Jan 2010 21:45:19 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 70B45140E4; Fri, 29 Jan 2010 21:45:13 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 3E345CF000D; Fri, 29 Jan 2010 14:45:13 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gmTIrNrjN8gc; Fri, 29 Jan 2010 14:45:13 -0700 (MST) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id 25EE5CF0007; Fri, 29 Jan 2010 14:45:13 -0700 (MST) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 0F7D12621B; Fri, 29 Jan 2010 14:45:13 -0700 (MST) Subject: [PATCH 3/7] IB/uverbs: use stack variable 'devnum' in ib_uverbs_add_one To: rdreier@cisco.com From: Alex Chiang Cc: linux-rdma@vger.kernel.org, justin.chen@hp.com, linux-kernel@vger.kernel.org Date: Fri, 29 Jan 2010 14:45:13 -0700 Message-ID: <20100129214512.17745.21978.stgit@bob.kio> In-Reply-To: <20100129214039.17745.38679.stgit@bob.kio> References: <20100129214039.17745.38679.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 29 Jan 2010 21:47:38 +0000 (UTC) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 3f11292..acae9ed 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -730,6 +730,7 @@ static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); static void ib_uverbs_add_one(struct ib_device *device) { + int devnum; struct ib_uverbs_device *uverbs_dev; if (!device->alloc_ucontext) @@ -743,12 +744,13 @@ static void ib_uverbs_add_one(struct ib_device *device) init_completion(&uverbs_dev->comp); spin_lock(&map_lock); - uverbs_dev->devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); - if (uverbs_dev->devnum >= IB_UVERBS_MAX_DEVICES) { + devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); + if (devnum >= IB_UVERBS_MAX_DEVICES) { spin_unlock(&map_lock); goto err; } - set_bit(uverbs_dev->devnum, dev_map); + uverbs_dev->devnum = devnum; + set_bit(devnum, dev_map); spin_unlock(&map_lock); uverbs_dev->ib_dev = device; @@ -758,7 +760,7 @@ static void ib_uverbs_add_one(struct ib_device *device) uverbs_dev->cdev.owner = THIS_MODULE; uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum); - if (cdev_add(&uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) + if (cdev_add(&uverbs_dev->cdev, IB_UVERBS_BASE_DEV + devnum, 1)) goto err_cdev; uverbs_dev->dev = device_create(uverbs_class, device->dma_device, @@ -781,7 +783,7 @@ err_class: err_cdev: cdev_del(&uverbs_dev->cdev); - clear_bit(uverbs_dev->devnum, dev_map); + clear_bit(devnum, dev_map); err: kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);