From patchwork Tue Jan 20 21:55:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian McMenamin X-Patchwork-Id: 3344 X-Patchwork-Delegate: lethal@linux-sh.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0KLqElV027121 for ; Tue, 20 Jan 2009 13:52:15 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758249AbZATV4I (ORCPT ); Tue, 20 Jan 2009 16:56:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757399AbZATV4F (ORCPT ); Tue, 20 Jan 2009 16:56:05 -0500 Received: from mk-filter-4-a-1.mail.uk.tiscali.com ([212.74.100.55]:51634 "EHLO mk-filter-4-a-1.mail.uk.tiscali.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755753AbZATV4B (ORCPT ); Tue, 20 Jan 2009 16:56:01 -0500 X-Trace: 130160455/mk-filter-4.mail.uk.tiscali.com/B2C/$b2c-THROTTLED-DYNAMIC/b2c-CUSTOMER-DYNAMIC-IP/80.44.176.170/None/adrian@newgolddream.dyndns.info X-SBRS: None X-RemoteIP: 80.44.176.170 X-IP-MAIL-FROM: adrian@newgolddream.dyndns.info X-MUA: Evolution 2.24.2 X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYEALbXdUlQLLCq/2dsb2JhbACBbLgWkCyFcw X-IronPort-AV: E=Sophos;i="4.37,296,1231113600"; d="scan'208";a="130160455" Received: from 80-44-176-170.dynamic.dsl.as9105.com (HELO newgolddream.info) ([80.44.176.170]) by smtp.tiscali.co.uk with ESMTP; 20 Jan 2009 21:55:52 +0000 Received: from [192.168.62.105] (bossclass.local [192.168.62.105]) by newgolddream.info (8.14.3/8.14.3/Debian-4) with ESMTP id n0KLtSmm006845; Tue, 20 Jan 2009 21:55:33 GMT Subject: Re: [PATCH] dma: fix up broken comparison in dma_alloc_from_coherent From: Adrian McMenamin To: Adrian McMenamin Cc: LKML , Paul Mundt , Andrew Morton , linux-sh , penberg@cs.helsinki.fi, dbaryshkov@gmail.com, penguin-kernel@i-love.sakura.ne.jp In-Reply-To: <8b67d60901201348r6a59928dw3fcf8c9c823d5c68@mail.gmail.com> References: <8b67d60901201348r6a59928dw3fcf8c9c823d5c68@mail.gmail.com> Date: Tue, 20 Jan 2009 21:55:07 +0000 Message-Id: <1232488507.6794.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 X-Spam-Status: No, score=-4.2 required=4.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on dragoneye X-Virus-Scanned: ClamAV 0.94.1rc1/8881/Tue Jan 20 14:48:51 2009 on newgolddream.info X-Virus-Status: Clean Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On Tue, 2009-01-20 at 21:48 +0000, Adrian McMenamin wrote: > Currently this code compares a size in bytes with a size in pages. > This patch makes both sides of the comparison bytes. Apologies, here it is without the line wrap. Currently this comparison is made between bytes and pages. This patch ensures it is bytes on both side of the comparison. Signed-off-by: Adrian McMenamin --- -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/kernel/dma-coherent.c +++ b/kernel/dma-coherent.c @@ -118,7 +118,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size, mem = dev->dma_mem; if (!mem) return 0; - if (unlikely(size > mem->size)) + if (unlikely(size > mem->size << PAGE_SHIFT)) return 0; pageno = bitmap_find_free_region(mem->bitmap, mem->size, order);