From patchwork Tue Feb 2 19:08:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chiang X-Patchwork-Id: 76475 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 o12JAkT2031411 for ; Tue, 2 Feb 2010 19:10:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932251Ab0BBTJA (ORCPT ); Tue, 2 Feb 2010 14:09:00 -0500 Received: from g4t0016.houston.hp.com ([15.201.24.19]:43237 "EHLO g4t0016.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932226Ab0BBTI4 (ORCPT ); Tue, 2 Feb 2010 14:08:56 -0500 Received: from g4t0009.houston.hp.com (g4t0009.houston.hp.com [16.234.32.26]) by g4t0016.houston.hp.com (Postfix) with ESMTP id 28C60140A4; Tue, 2 Feb 2010 19:08:56 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g4t0009.houston.hp.com (Postfix) with ESMTP id 14C4AC02E; Tue, 2 Feb 2010 19:08:56 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 0048ACF000A; Tue, 2 Feb 2010 12:08:56 -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 cjNuKHRiyK3U; Tue, 2 Feb 2010 12:08:55 -0700 (MST) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id E04F8CF0007; Tue, 2 Feb 2010 12:08:55 -0700 (MST) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id C7816261D3; Tue, 2 Feb 2010 12:08:55 -0700 (MST) Subject: [PATCH v2 14/18] IB/ucm: use stack variable 'devnum' in ib_ucm_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: Tue, 02 Feb 2010 12:08:55 -0700 Message-ID: <20100202190855.28217.68785.stgit@bob.kio> In-Reply-To: <20100202185235.28217.64521.stgit@bob.kio> References: <20100202185235.28217.64521.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]); Tue, 02 Feb 2010 19:10:46 +0000 (UTC) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index f504c9b..7ff3300 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -1239,6 +1239,7 @@ static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); static void ib_ucm_add_one(struct ib_device *device) { + int devnum; struct ib_ucm_device *ucm_dev; if (!device->alloc_ucontext || @@ -1251,16 +1252,17 @@ static void ib_ucm_add_one(struct ib_device *device) ucm_dev->ib_dev = device; - ucm_dev->devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES); - if (ucm_dev->devnum >= IB_UCM_MAX_DEVICES) + devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES); + if (devnum >= IB_UCM_MAX_DEVICES) goto err; - set_bit(ucm_dev->devnum, dev_map); + ucm_dev->devnum = devnum; + set_bit(devnum, dev_map); cdev_init(&ucm_dev->cdev, &ucm_fops); ucm_dev->cdev.owner = THIS_MODULE; kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); - if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) + if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + devnum, 1)) goto err; ucm_dev->dev.class = &cm_class; @@ -1281,7 +1283,7 @@ err_dev: device_unregister(&ucm_dev->dev); err_cdev: cdev_del(&ucm_dev->cdev); - clear_bit(ucm_dev->devnum, dev_map); + clear_bit(devnum, dev_map); err: kfree(ucm_dev); return;