iommu/mtk_iommu: Use devm_kcalloc() instead of devm_kzalloc()
authorErick Archer <erick.archer@gmx.com>
Sun, 11 Feb 2024 18:22:50 +0000 (19:22 +0100)
committerJoerg Roedel <jroedel@suse.de>
Fri, 16 Feb 2024 14:18:12 +0000 (15:18 +0100)
commitb07cd3b746cfe9a4524a5a7337fcf4ccb933509b
treeb8bd4a2824a05984e5a51d5fe30560ab83b39c49
parent54be6c6c5ae8e0d93a6c4641cb7528eb0b6ba478
iommu/mtk_iommu: Use devm_kcalloc() instead of devm_kzalloc()

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
Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Signed-off-by: Erick Archer <erick.archer@gmx.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20240211182250.12656-1-erick.archer@gmx.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/mtk_iommu.c
drivers/iommu/mtk_iommu_v1.c