lkml.org 
[lkml]   [2007]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] dma_declare_coherent_memory wrong allocation
    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.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-04-21 09:11    [W:2.489 / U:0.484 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site