]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/admgpu: fix dereferencing null pointer context
authorJesse Zhang <jesse.zhang@amd.com>
Thu, 9 May 2024 02:57:04 +0000 (10:57 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 23 May 2024 19:09:15 +0000 (15:09 -0400)
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

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Tim Huang <Tim.Huang@amd.com>
Reviewed-by: Tim Huang <Tim.Huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c

index ca5c86e5f7cd671a651d61357ab52d3c53a1e7f3..8e8afbd237bcdffb74a907d30fc74e3dfd850ff4 100644 (file)
@@ -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;