drm/admgpu: fix dereferencing null pointer context
Subsystems (2)
PATCH 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
@@ -334,7 +334,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, sizeset_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
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Jesse,
Quoted 25 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Jesse Zhang
Sent: Tuesday, May 21, 2024 11:26 AM
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] drm/admgpu: fix dereferencing null pointer contextWhen user space sets an invalid ta type, the pointer context will be empty. So it need to check the pointer context before using it
Signed-off-by Jesse Zhang <[email protected]>--- 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 +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c static ssize_t ta_if_invoke_debugfs_write(struct file · line 338
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1
-1@@ -334,7 +334,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, sizeset_ta_context_funcs (psp, ta_type, &context); -if (!context->initialized) { +if (context && !context->initialized) {
This can help to avoid using the empty pointer context but still needs to handle the context == NULL case and return an error.
Tim
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0
-0dev_err (adev->dev,"TA is not initialized\n" ); ret = -EINVAL ;goto err_free_shared_buf;--
2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Tim,
-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Tuesday, May 21, 2024 2:12 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: RE: [PATCH 4/4] drm/admgpu: fix dereferencing null pointer context
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Jesse,
Quoted 30 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Jesse Zhang
Sent: Tuesday, May 21, 2024 11:26 AM
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] drm/admgpu: fix dereferencing null pointer contextWhen user space sets an invalid ta type, the pointer context will be empty. So it need to check the pointer context before using it
Signed-off-by Jesse Zhang <[email protected]>--- 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 +0
-0@@ -334,7 +334,7 @@ static ssize_t ta_if_invoke_debugfs_write(structfile *fp, const char *buf, size
set_ta_context_funcs(psp, ta_type, &context);
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size · line 337
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1
-1-if (!context->initialized) { +if (context && !context->initialized) {
This can help to avoid using the empty pointer context but still needs to handle the context == NULL case and return an error. [Zhang, Jesse(Jie)] Yes, Thanks, I will update the patch.
Thanks
Jesse
Tim
Quoted 5 lines
dev_err(adev->dev, "TA is not initialized\n"); ret = -EINVAL; goto err_free_shared_buf;--
2.25.1