Re: [PATCH] iommu/mtk_iommu: Use devm_kcalloc() instead of devm_kzalloc()

Matthias Brugger
2024-02-12T15:50:18Z

On 11/02/2024 19:22, Erick Archer wrote:
> This is an effort to get rid of all multiplications from allocation
> functions in order to prevent integer overflows [1].
>
> Here the multiplication is obviously safe because MTK_PROTECT_PA_ALIGN
> is defined as a literal value of 256 or 128.
>
> For the "mtk_iommu.c" file: 256
> For the "mtk_iommu_v1.c" file: 128
>
> However, using devm_kcalloc() is more appropriate [2] and improves
> readability. This patch has no effect on runtime behavior.
>
> Link: https://github.com/KSPP/linux/issues/162 [1]
> Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2]
> Signed-off-by: Erick Archer <erick.archer@gmx.com>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>