[PATCH 3/5] drm/amdgpu: Fix null pointer dereference to aca_handle

Ma Jun Jun.Ma2 at amd.com
Mon May 13 08:56:14 UTC 2024


Check handle pointer before using it

Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
index 28febf33fb1b..e969a7d77b4d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
@@ -279,7 +279,7 @@ static struct aca_bank_error *get_bank_error(struct aca_error *aerr, struct aca_
 int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_info *info,
 				   enum aca_error_type type, u64 count)
 {
-	struct aca_error_cache *error_cache = &handle->error_cache;
+	struct aca_error_cache *error_cache;
 	struct aca_bank_error *bank_error;
 	struct aca_error *aerr;
 
@@ -289,6 +289,10 @@ int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_in
 	if (!count)
 		return 0;
 
+	error_cache = &handle->error_cache;
+	if (!error_cache)
+		return -EINVAL;
+
 	aerr = &error_cache->errors[type];
 	bank_error = get_bank_error(aerr, info);
 	if (!bank_error)
-- 
2.34.1



More information about the amd-gfx mailing list