[PATCH 1/2] drm/amdgpu: Fix null ptr when calling query_ras_error_count

Andrey Grodzovsky andrey.grodzovsky at amd.com
Tue Aug 13 17:50:41 UTC 2019


ras_err_data.err_addr was never allocated

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 50c13b0..d9fb860 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1011,6 +1011,21 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 	int ret;
 	struct ras_err_data err_data = {0, 0, 0, NULL};
 
+	/* Allocate enough to serve max  number of requests*/
+	int err_addr_size = data->ring_size / data->aligned_element_size *
+			   obj->adev->umc.umc_inst_num *
+			   obj->adev->umc.channel_inst_num;
+
+	err_data.err_addr = kcalloc(err_addr_size,
+				    sizeof(*err_data.err_addr),
+				    GFP_KERNEL);
+
+	if (!err_data.err_addr) {
+		DRM_ERROR("Not enough memory!");
+		return;
+	}
+
+
 	while (data->rptr != data->wptr) {
 		rmb();
 		memcpy(&entry, &data->ring[data->rptr],
@@ -1039,6 +1054,8 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 			}
 		}
 	}
+
+	 kfree(err_data.err_addr);
 }
 
 static void amdgpu_ras_interrupt_process_handler(struct work_struct *work)
-- 
2.7.4



More information about the amd-gfx mailing list