Skip to content

Commit 3622b86

Browse files
author
Christoph Hellwig
committed
dma-mapping: reject GFP_COMP for noncoherent allocations
While not quite as bogus as for the dma-coherent allocations that were fixed earlier, GFP_COMP for these allocations has no benefits for the dma-direct case, and can't be supported at all by dma dma-iommu backend which splits up allocations into smaller orders. Due to an oversight in ffcb754 that flag stopped being cleared for all dma allocations, but only got rejected for coherent ones, so fix up these callers to not allow __GFP_COMP as well after the sound code has been fixed to not ask for it. Fixes: ffcb754 ("dma-mapping: reject __GFP_COMP in dma_alloc_attrs") Reported-by: Mikhail Gavrilov <[email protected]> Reported-by: Kai Vehmanen <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Takashi Iwai <[email protected]> Tested-by: Mikhail Gavrilov <[email protected]> Tested-by: Kai Vehmanen <[email protected]>
1 parent db91832 commit 3622b86

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/dma/mapping.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size,
560560
return NULL;
561561
if (WARN_ON_ONCE(gfp & (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM)))
562562
return NULL;
563+
if (WARN_ON_ONCE(gfp & __GFP_COMP))
564+
return NULL;
563565

564566
size = PAGE_ALIGN(size);
565567
if (dma_alloc_direct(dev, ops))
@@ -645,6 +647,8 @@ struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
645647

646648
if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES))
647649
return NULL;
650+
if (WARN_ON_ONCE(gfp & __GFP_COMP))
651+
return NULL;
648652

649653
if (ops && ops->alloc_noncontiguous)
650654
sgt = ops->alloc_noncontiguous(dev, size, dir, gfp, attrs);

0 commit comments

Comments
 (0)