From patchwork Tue Jul 26 07:19:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 1007362 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6Q7H5bZ024993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 26 Jul 2011 07:17:26 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qlbsr-00026b-J9; Tue, 26 Jul 2011 07:16:53 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qlbsr-0001mn-7F; Tue, 26 Jul 2011 07:16:53 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qlbsn-0001mS-V6 for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2011 07:16:50 +0000 X-ASG-Debug-ID: 1311664607-082deaf80001-tbGyMd Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id Oy3YJDqfxqYfH7TV; Tue, 26 Jul 2011 00:16:47 -0700 (PDT) X-Barracuda-Envelope-From: leoy@marvell.com Received: from localhost (unknown [10.38.34.150]) by maili.marvell.com (Postfix) with ESMTP id 7FB8B8A002; Tue, 26 Jul 2011 00:16:47 -0700 (PDT) From: Leo Yan To: linux-arm-kernel@lists.infradead.org, Jean-Christophe PLAGNIOL-VILLARD , linux-kernel@vger.kernel.org, Andrew Morton , Leo Yan X-ASG-Orig-Subj: [PATCH] lib/genalloc: fix gen_pool_virt_to_phys locking Subject: [PATCH] lib/genalloc: fix gen_pool_virt_to_phys locking Date: Tue, 26 Jul 2011 15:19:01 +0800 X-ASG-Orig-Subj: [PATCH] lib/genalloc: fix gen_pool_virt_to_phys locking Message-Id: <1311664741-21336-1-git-send-email-leoy@marvell.com> X-Mailer: git-send-email 1.7.4.1 X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1311664607 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110726_031650_094827_382B9C2B X-CRM114-Status: GOOD ( 11.35 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 26 Jul 2011 07:17:26 +0000 (UTC) The func gen_pool_virt_to_phys will iterate the chunk list; if find the correct chunk it should need release pool's lock. Signed-off-by: Leo Yan --- lib/genalloc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lib/genalloc.c b/lib/genalloc.c index 577ddf8..e625df5 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -92,8 +92,10 @@ phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long addr) list_for_each(_chunk, &pool->chunks) { chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk); - if (addr >= chunk->start_addr && addr < chunk->end_addr) + if (addr >= chunk->start_addr && addr < chunk->end_addr) { + read_unlock(&pool->lock); return chunk->phys_addr + addr - chunk->start_addr; + } } read_unlock(&pool->lock);