drm/amdgpu: Avoid possiblity of kernel crash in 'gmc_v8_0, gmc_v7_0_init_microcode()'
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Thu, 13 Jul 2023 13:13:49 +0000 (18:43 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 18 Jul 2023 15:09:30 +0000 (11:09 -0400)
If the function 'gmc_v8_0_ or gmc_v7_0_init_microcode()' fails, the
driver will just fail to load, hence return -EINVAL rather having BUG(),
fixes WARNING: Do not crash the kernel unless it is absolutely
unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead
of BUG() or variants

Fixes: 2f77b5931f68 ("drm/amdgpu: Fix error & warnings in gmc_v8_0.c")
Fixes: 0cfc1d683046 ("drm/amdgpu: Fix errors & warnings in gmc_ v6_0, v7_0.c")
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
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: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

index 0629b68..6a6929a 100644 (file)
@@ -150,7 +150,7 @@ static int gmc_v7_0_init_microcode(struct amdgpu_device *adev)
        case CHIP_MULLINS:
                return 0;
        default:
-               BUG();
+               return -EINVAL;
        }
 
        snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mc.bin", chip_name);
index 23bfadc..5af2352 100644 (file)
@@ -252,7 +252,7 @@ static int gmc_v8_0_init_microcode(struct amdgpu_device *adev)
        case CHIP_VEGAM:
                return 0;
        default:
-               BUG();
+               return -EINVAL;
        }
 
        snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mc.bin", chip_name);