drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent
authorjsg <jsg@openbsd.org>
Fri, 30 Aug 2024 04:03:30 +0000 (04:03 +0000)
committerjsg <jsg@openbsd.org>
Fri, 30 Aug 2024 04:03:30 +0000 (04:03 +0000)
From Jesse Zhang
3cc03d1dbdcf88d3c05578c286a2e8a07befac93 in linux-6.6.y/6.6.48
511a623fb46a6cf578c61d4f2755783c48807c77 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c

index 8da9740..8c5e7d0 100644 (file)
@@ -766,11 +766,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;