]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/core/memalloc.c
ALSA: Fix allocation size calculation in snd_dma_alloc_pages_fallback()
[linux-2.6-omap-h63xx.git] / sound / core / memalloc.c
index f0c3b1d6da810f75c69b283f38b35fb3363f8950..a7b46ec72f3231191cb6f81d7c816f6b011bc696 100644 (file)
@@ -277,11 +277,16 @@ int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,
        int err;
 
        while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
+               size_t aligned_size;
                if (err != -ENOMEM)
                        return err;
-               size >>= 1;
                if (size <= PAGE_SIZE)
                        return -ENOMEM;
+               aligned_size = PAGE_SIZE << get_order(size);
+               if (size != aligned_size)
+                       size = aligned_size;
+               else
+                       size >>= 1;
        }
        if (! dmab->area)
                return -ENOMEM;