drm/amdgpu: avoid null pointer dereference
authorGuchun Chen <guchun.chen@amd.com>
Tue, 17 Sep 2019 09:49:29 +0000 (17:49 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 3 Oct 2019 14:10:59 +0000 (09:10 -0500)
null ptr should be checked first to avoid null ptr access

Signed-off-by: Guchun Chen <guchun.chen@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 24fecaae415c5856b5b2aae4b70ae4aa58600017..83b681a16e5669b2e9f64a86087ed128417cd7bf 100644 (file)
@@ -1336,13 +1336,13 @@ static int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev)
 {
        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        struct ras_err_handler_data *data;
-       struct amdgpu_ras_eeprom_control *control =
-                                       &adev->psp.ras.ras->eeprom_control;
+       struct amdgpu_ras_eeprom_control *control;
        int save_count;
 
        if (!con || !con->eh_data)
                return 0;
 
+       control = &con->eeprom_control;
        data = con->eh_data;
        save_count = data->count - control->num_recs;
        /* only new entries are saved */