Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=399154be2dcb6a58dbde9682162c38113cf3e40b Commit: 399154be2dcb6a58dbde9682162c38113cf3e40b Parent: 2cae367e4854ff055c4f5e8aacd56b0eeec9f6cb Author: Matthew Wilcox <[EMAIL PROTECTED]> AuthorDate: Mon Dec 3 12:10:24 2007 -0500 Committer: Matthew Wilcox <[EMAIL PROTECTED]> CommitDate: Tue Dec 4 10:39:56 2007 -0500
dmapool: Validate parameters to dma_pool_create Check that 'align' is a power of two, like the API specifies. Align 'size' to 'align' correctly -- the current code has an off-by-one. The ALIGN macro in kernel.h doesn't. Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]> Acked-by: David S. Miller <[EMAIL PROTECTED]> --- mm/dmapool.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index b5ff9ce..744d541 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -106,17 +106,18 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, { struct dma_pool *retval; - if (align == 0) + if (align == 0) { align = 1; - if (size == 0) + } else if (align & (align - 1)) { return NULL; - else if (size < align) - size = align; - else if ((size % align) != 0) { - size += align + 1; - size &= ~(align - 1); } + if (size == 0) + return NULL; + + if ((size % align) != 0) + size = ALIGN(size, align); + if (allocation == 0) { if (PAGE_SIZE < size) allocation = size; - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html