drm/amdgpu: Use kzalloc instead of kmalloc+__GFP_ZERO in amdgpu_ras.c
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Tue, 19 Dec 2023 13:56:22 +0000 (19:26 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 3 Jan 2024 16:16:06 +0000 (11:16 -0500)
Fixes the below smatch warnings:

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:2543 amdgpu_ras_recovery_init() warn: Please consider using kzalloc instead of kmalloc
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:2830 amdgpu_ras_init() warn: Please consider using kzalloc instead of kmalloc

Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

index bad62141f7084a6aeb5851572d8d2091471a419e..e541e69259184dc7dfe551f68fd8a11bb865af10 100644 (file)
@@ -2540,7 +2540,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
                return 0;
 
        data = &con->eh_data;
-       *data = kmalloc(sizeof(**data), GFP_KERNEL | __GFP_ZERO);
+       *data = kzalloc(sizeof(**data), GFP_KERNEL);
        if (!*data) {
                ret = -ENOMEM;
                goto out;
@@ -2827,10 +2827,10 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
        if (con)
                return 0;
 
-       con = kmalloc(sizeof(struct amdgpu_ras) +
+       con = kzalloc(sizeof(*con) +
                        sizeof(struct ras_manager) * AMDGPU_RAS_BLOCK_COUNT +
                        sizeof(struct ras_manager) * AMDGPU_RAS_MCA_BLOCK_COUNT,
-                       GFP_KERNEL|__GFP_ZERO);
+                       GFP_KERNEL);
        if (!con)
                return -ENOMEM;