ARM: dma-mapping: Treat bitmap size as allocation failure

bitmap_find_next_zero_area() uses an out-of-range return value to
indicate failure. Check for values greater than or equal to the bitmap
size so the caller does not depend on the exact failure sentinel.

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
This commit is contained in:
Yury Norov 2026-07-08 22:03:07 -04:00
parent ae44a037ac
commit d00e89988e

View File

@ -773,7 +773,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
start = bitmap_find_next_zero_area(mapping->bitmaps[i],
mapping->bits, 0, count, align);
if (start > mapping->bits)
if (start >= mapping->bits)
continue;
bitmap_set(mapping->bitmaps[i], start, count);
@ -794,7 +794,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
start = bitmap_find_next_zero_area(mapping->bitmaps[i],
mapping->bits, 0, count, align);
if (start > mapping->bits) {
if (start >= mapping->bits) {
spin_unlock_irqrestore(&mapping->lock, flags);
return DMA_MAPPING_ERROR;
}