[PATCH] ARM/dma-mapping: Remove CMA code when not built with CMA

Christoph Hellwig hch at lst.de
Wed Mar 9 23:00:41 PST 2022


On Wed, Mar 09, 2022 at 09:51:07AM -0800, Kees Cook wrote:
> The MAX_CMA_AREAS could be set to 0, which would result in code that would
> attempt to operate beyond the end of a zero-sized array. If CONFIG_CMA
> is disabled, just remove this code entirely. Found when building with
> -Warray-bounds:
> 
> arch/arm/mm/dma-mapping.c:396:22: warning: array subscript <unknown> is outside array bounds of 'str
> uct dma_contig_early_reserve[0]' [-Warray-bounds]
>   396 |         dma_mmu_remap[dma_mmu_remap_num].size = size;
>       |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
> arch/arm/mm/dma-mapping.c:389:40: note: while referencing 'dma_mmu_remap'
>   389 | static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] __initdata;

Looks good:

Reviewed-by: Christoph Hellwig <hch at lst.de>



More information about the linux-arm-kernel mailing list