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

David Hildenbrand
2022-03-10T08:23:54Z

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

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

--
Thanks,

David / dhildenb