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

David Hildenbrand david at redhat.com
Thu Mar 10 00:23:44 PST 2022


On 09.03.22 18:51, 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;
>       |                                        ^~~~~~~~~~~~~
> 
> Cc: Russell King <linux at armlinux.org.uk>
> Cc: Logan Gunthorpe <logang at deltatee.com>
> Cc: Martin Oliveira <martin.oliveira at eideticom.com>
> Cc: David Hildenbrand <david at redhat.com>
> Cc: Andrew Morton <akpm at linux-foundation.org>
> Cc: Stephen Rothwell <sfr at canb.auug.org.au>
> Cc: Zi Yan <ziy at nvidia.com>
> Cc: Hari Bathini <hbathini at linux.ibm.com>
> Cc: Minchan Kim <minchan at kernel.org>
> Cc: Mike Kravetz <mike.kravetz at oracle.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Signed-off-by: Kees Cook <keescook at chromium.org>

Reviewed-by: David Hildenbrand <david at redhat.com>


-- 
Thanks,

David / dhildenb




More information about the linux-arm-kernel mailing list