]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu: Fix potential null pointer derefernce
authorStanley.Yang <Stanley.Yang@amd.com>
Wed, 27 Sep 2023 08:22:29 +0000 (16:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:14:45 +0000 (17:14 +0000)
[ Upstream commit 80285ae1ec8717b597b20de38866c29d84d321a1 ]

The amdgpu_ras_get_context may return NULL if device
not support ras feature, so add check before using.

Signed-off-by: Stanley.Yang <Stanley.Yang@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 8940ee73f2dfe2c0fb82dc80c52105b3921a8274..ecc61a6d13e13ac421953f213f63e51bbfb0eed7 100644 (file)
@@ -5399,7 +5399,8 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
         * Flush RAM to disk so that after reboot
         * the user can read log and see why the system rebooted.
         */
-       if (need_emergency_restart && amdgpu_ras_get_context(adev)->reboot) {
+       if (need_emergency_restart && amdgpu_ras_get_context(adev) &&
+               amdgpu_ras_get_context(adev)->reboot) {
                DRM_WARN("Emergency reboot.");
 
                ksys_sync_helper();