Re: [PATCH] dma_declare_coherent_memory wrong allocation

From: James Bottomley
Date: Sun Apr 22 2007 - 12:52:44 EST


On Fri, 2007-04-13 at 20:08 +0200, Guennadi Liakhovetski wrote:
> 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.

No, it's a longstanding bug in the x86 implementation, thanks for
finding it.

> - int bitmap_size = (pages + 31)/32;
> + int bitmap_size = DIV_ROUND_UP(pages, 8);

This isn't quite right. Bitmaps are arrays of longs, not arrays of
bytes. The bug is forgetting that kmalloc() takes bytes ...

How about

int bitmap_size = DIV_ROUNDUP(pages, 32) * 4;

?

James


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/