[AMD Official Use Only - AMD Internal Distribution Only]

The patch is

Reviewed-by: Hawking Zhang <[email protected]>

Please make another change to set cper.enabled to be true *only* after cper 
ring is successfully created.

Regards,
Hawking

-----Original Message-----
From: Liu, Xiang(Dean) <[email protected]>
Sent: Monday, February 24, 2025 21:14
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; 
Dong, Andy <[email protected]>; Liu, Xiang(Dean) <[email protected]>
Subject: [PATCH] drm/amdgpu: Check if CPER enabled when generating CPER

In the case of CPER disabled, generating CPER will cause kernel NULL pointer 
dereference without checking.

Signed-off-by: Xiang Liu <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 3 +++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
index d11593cd1922..ffd4c64e123c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
@@ -392,6 +392,9 @@ static void aca_banks_generate_cper(struct amdgpu_device 
*adev,
        struct aca_bank_node *node;
        struct aca_bank *bank;

+       if (!adev->cper.enabled)
+               return;
+
        if (!banks || !count) {
                dev_warn(adev->dev, "fail to generate cper records\n");
                return;
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index 7c4ff12269d9..81e9b443ca0a 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -716,8 +716,9 @@ int amdgpu_dpm_send_rma_reason(struct amdgpu_device *adev)
        ret = smu_send_rma_reason(smu);
        mutex_unlock(&adev->pm.mutex);

-       if (amdgpu_cper_generate_bp_threshold_record(adev))
-               dev_warn(adev->dev, "fail to generate bad page threshold cper 
records\n");
+       if (adev->cper.enabled)
+               if (amdgpu_cper_generate_bp_threshold_record(adev))
+                       dev_warn(adev->dev, "fail to generate bad page 
threshold cper
+records\n");

        return ret;
 }
--
2.34.1

Reply via email to