]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent
authorJesse Zhang <jesse.zhang@amd.com>
Thu, 23 May 2024 09:14:45 +0000 (17:14 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 29 May 2024 21:03:20 +0000 (17:03 -0400)
The pointer parent may be NULLed by the function amdgpu_vm_pt_parent.
To make the code more robust, check the pointer parent.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c

index 7fdd306a48a0ecb3729a3632c1c38385802e295c..f07647a9a9d97bb87bf1c6704cf12674d3f89b4e 100644 (file)
@@ -706,11 +706,15 @@ int amdgpu_vm_pde_update(struct amdgpu_vm_update_params *params,
                         struct amdgpu_vm_bo_base *entry)
 {
        struct amdgpu_vm_bo_base *parent = amdgpu_vm_pt_parent(entry);
-       struct amdgpu_bo *bo = parent->bo, *pbo;
+       struct amdgpu_bo *bo, *pbo;
        struct amdgpu_vm *vm = params->vm;
        uint64_t pde, pt, flags;
        unsigned int level;
 
+       if (WARN_ON(!parent))
+               return -EINVAL;
+
+       bo = parent->bo;
        for (level = 0, pbo = bo->parent; pbo; ++level)
                pbo = pbo->parent;