Skip to contentSkip to conversation

drm/admgpu: fix dereferencing null pointer context

PATCH Superseded Jesse Zhang 2 participants 2 messages May 21, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/4 drm/admgpu: fix dereferencing null pointer context

When user space sets an invalid ta type, the pointer context will be empty. So it need to check the pointer context before using it

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -1
index ca5c86e5f7cd..8e8afbd237bc 100644
@@ -334,7 +334,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
 
 	set_ta_context_funcs(psp, ta_type, &context);
 
-	if (!context->initialized) {
+	if (!context || !context->initialized) {
 		dev_err(adev->dev, "TA is not initialized\n");
 		ret = -EINVAL;
 		goto err_free_shared_buf;
Signature · 1 line
2.25.1
Reviewed-by on v2 4/4
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Series is,

Quoted 36 lines

-----Original Message-----
From: Jesse Zhang <[email protected]>
Sent: Tuesday, May 21, 2024 3:18 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH 4/4 V2] drm/admgpu: fix dereferencing null pointer context

When user space sets an invalid ta type, the pointer context will be empty. So it need to check the pointer context before using it

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -1
index ca5c86e5f7cd..8e8afbd237bc 100644
@@ -334,7 +334,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file
 *fp, const char *buf, size
 
      set_ta_context_funcs(psp, ta_type, &context);
 
-     if (!context->initialized) {
+     if (!context || !context->initialized) {
              dev_err(adev->dev, "TA is not initialized\n");
              ret = -EINVAL;
              goto err_free_shared_buf;

--
2.25.1