drm/amdgpu: Fix kcalloc over kzalloc in 'gmc_v9_0_init_mem_ranges'
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Fri, 18 Aug 2023 06:27:03 +0000 (11:57 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 30 Aug 2023 19:20:02 +0000 (15:20 -0400)
Replace kzalloc(n * sizeof(...), ...) with kcalloc(n, sizeof(...), ...)
since kcalloc is the preferred API in case of allocating with multiply.

Fixes the below:

WARNING: Prefer kcalloc over kzalloc with multiply

Cc: Guchun Chen <guchun.chen@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index f9a5a2c0573e4110969bf015c36b4d4590001329..0673cda547bbec65e4cf035e7d428811f7a915c4 100644 (file)
@@ -1972,10 +1972,9 @@ static int gmc_v9_0_init_mem_ranges(struct amdgpu_device *adev)
 {
        bool valid;
 
-       adev->gmc.mem_partitions = kzalloc(
-               MAX_MEM_RANGES * sizeof(struct amdgpu_mem_partition_info),
-               GFP_KERNEL);
-
+       adev->gmc.mem_partitions = kcalloc(MAX_MEM_RANGES,
+                                          sizeof(struct amdgpu_mem_partition_info),
+                                          GFP_KERNEL);
        if (!adev->gmc.mem_partitions)
                return -ENOMEM;