From: Andrew Morton <akpm@linux-foundation.org>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma_declare_coherent_memory wrong allocation
Date: Sat, 21 Apr 2007 00:08:17 -0700 [thread overview]
Message-ID: <20070421000817.124e917b.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.60.0704132000030.5919@poirot.grange>
On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> Hi
>
> Either I've finally gone blind on this Friday 13th or... Looks like this
> almost 3 year old function has a bug. Patch below compile-tested... in a
> way.
>
> Thanks
> Guennadi
> ---
> Guennadi Liakhovetski
>
> dma_declare_coherent_memory() allocates a bitmap 1 bit per page, it
> calculates the bitmap size based on size of long, but allocates bytes...
>
> Signed-off-by: G. Liakhovetski <g.liakhovetski@gmx.de>
>
> diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
> index 3ebcea0..3d55226 100644
> --- a/arch/i386/kernel/pci-dma.c
> +++ b/arch/i386/kernel/pci-dma.c
> @@ -77,7 +77,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
> {
> void __iomem *mem_base = NULL;
> int pages = size >> PAGE_SHIFT;
> - int bitmap_size = (pages + 31)/32;
> + int bitmap_size = DIV_ROUND_UP(pages, 8);
>
> if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
> goto out;
Looks that way to me, too.
It also hopes like hell that `size' was a multiple of PAGE_SIZE.
next prev parent reply other threads:[~2007-04-21 7:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 18:08 [PATCH] dma_declare_coherent_memory wrong allocation Guennadi Liakhovetski
2007-04-21 7:08 ` Andrew Morton [this message]
2007-04-21 11:01 ` Guennadi Liakhovetski
2007-04-22 16:52 ` James Bottomley
2007-04-22 22:45 ` Guennadi Liakhovetski
2007-04-22 22:49 ` Guennadi Liakhovetski
2007-04-23 15:58 ` James Bottomley
2007-04-23 20:45 ` Guennadi Liakhovetski
2007-04-26 13:47 ` James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070421000817.124e917b.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=James.Bottomley@SteelEye.com \
--cc=g.liakhovetski@gmx.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox