From patchwork Tue Feb 8 14:59:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 82350 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2B795B70FF for ; Wed, 9 Feb 2011 01:59:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754727Ab1BHO7R (ORCPT ); Tue, 8 Feb 2011 09:59:17 -0500 Received: from mail-gy0-f174.google.com ([209.85.160.174]:62800 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753937Ab1BHO7Q (ORCPT ); Tue, 8 Feb 2011 09:59:16 -0500 Received: by mail-gy0-f174.google.com with SMTP id 11so2244671gyb.19 for ; Tue, 08 Feb 2011 06:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=hw8JYZxOdUX6JWhvhC8dVf7QG10vl241OgjDXkqGapU=; b=tGtev4k4UAh/5k7ZHDxpch557KMkFvsZ1b2J18qszlTtZnJqsvSIgnA7HxbrnYRqQ1 vkhjZFnpRIWgLlJTfpaD0c5axU1asCcIVLERc16vNOMmv2LIAgpocMpaNI8LYKsHtTyO 9M9Lycubc9J70Ad941F2sEFHrvgedR7dHn4lI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Q4h+I9jz3efHNYXxyidoSBNXZVvgzzz1wvK/DrNOrR3ZvT0NVo3gh+OA1u/NHiLMPs hIcuVAE7e46UqKbNA44K4ooC+cLZBJlYKA6coBn8cjTFKzX8pGKrQcNl5Rcc3ei//UzP 1qcLbIfbaLmO1JQDV83tR4lJkjqJrYR3eoa/g= Received: by 10.90.115.10 with SMTP id n10mr19604agc.144.1297177150280; Tue, 08 Feb 2011 06:59:10 -0800 (PST) Received: from localhost.localdomain (p8025-adsao01yokonib2-acca.kanagawa.ocn.ne.jp [219.161.30.25]) by mx.google.com with ESMTPS id 35sm7169718ano.31.2011.02.08.06.59.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Feb 2011 06:59:09 -0800 (PST) From: Akinobu Mita To: sparclinux@vger.kernel.org Cc: Akinobu Mita , "David S. Miller" Subject: [PATCH] sparc: fix size argument to find_next_zero_bit() Date: Tue, 8 Feb 2011 23:59:50 +0900 Message-Id: <1297177190-1423-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1297177190-1423-1-git-send-email-akinobu.mita@gmail.com> References: <1297177190-1423-1-git-send-email-akinobu.mita@gmail.com> Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org iommu_alloc_ctx() finds a zero bit in iommu->ctx_bitmap. It starts searching from iommu->ctx_lowest_free to the end of the bitmap. But the size argument to find_next_zero_bit() in iommu_alloc_ctx() is wrong. It should be the bitmap size, not the maximum size to search from the offset argument. Fortunately iommu->ctx_lowest_free is almost unused and it will not be more than 1. So the bug wasted only 1-bit at the end of iommu->ctx_bitmap. Signed-off-by: Akinobu Mita Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- arch/sparc/kernel/iommu.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index 47977a7..72509d0 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -255,10 +255,9 @@ static inline iopte_t *alloc_npages(struct device *dev, struct iommu *iommu, static int iommu_alloc_ctx(struct iommu *iommu) { int lowest = iommu->ctx_lowest_free; - int sz = IOMMU_NUM_CTXS - lowest; - int n = find_next_zero_bit(iommu->ctx_bitmap, sz, lowest); + int n = find_next_zero_bit(iommu->ctx_bitmap, IOMMU_NUM_CTXS, lowest); - if (unlikely(n == sz)) { + if (unlikely(n == IOMMU_NUM_CTXS)) { n = find_next_zero_bit(iommu->ctx_bitmap, lowest, 1); if (unlikely(n == lowest)) { printk(KERN_WARNING "IOMMU: Ran out of contexts.\n");