drm/amdgpu: check for allocation failure in amdgpu_vkms_sw_init()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 6 Aug 2021 15:05:18 +0000 (18:05 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Aug 2021 20:12:23 +0000 (16:12 -0400)
Check whether the kcalloc() fails and return -ENOMEM if it does.

Fixes: 84ec374bd58036 ("drm/amdgpu: create amdgpu_vkms (v4)")
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c

index 50bdc39733aa1906e8ca4e06b5b74b6c128d53b2..ce982afeff913e7ac064954a0a384eb06a5512f7 100644 (file)
@@ -482,6 +482,8 @@ static int amdgpu_vkms_sw_init(void *handle)
                return r;
 
        adev->amdgpu_vkms_output = kcalloc(adev->mode_info.num_crtc, sizeof(struct amdgpu_vkms_output), GFP_KERNEL);
+       if (!adev->amdgpu_vkms_output)
+               return -ENOMEM;
 
        /* allocate crtcs, encoders, connectors */
        for (i = 0; i < adev->mode_info.num_crtc; i++) {