]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARM: dma-mapping: fix error path for memory allocation failure
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 27 Jul 2012 15:12:50 +0000 (17:12 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 30 Jul 2012 10:25:45 +0000 (12:25 +0200)
This patch fixes incorrect check in error path. When the allocation of
first page fails, the kernel ops appears due to accessing -1 element of
the pages array.

Reported-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
arch/arm/mm/dma-mapping.c

index a2881c98fb03bb6de82a48484ecd4c44db44d91d..cbdeaf4a339218027b8d77a6dd7f7bc91d05dfec 100644 (file)
@@ -961,7 +961,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t
 
        return pages;
 error:
-       while (--i)
+       while (i--)
                if (pages[i])
                        __free_pages(pages[i], 0);
        if (array_size <= PAGE_SIZE)