drm/gpuvm: Do not prepare NULL objects
Subsystems (3)
PATCH 1/1 drm/gpuvm: Do not prepare NULL objects
Statis analysis issue:
drm_gpuvm_prepare_range issues an exec_object_prepare call to all drm_gem_objects mapped between addr and addr + range. However, it is possible (albeit very unlikely) that the objects found through drm_gpuvm_for_each_va_range (as connected to va->gem) are NULL, as seen in other functions such as drm_gpuva_link and drm_gpuva_unlink_defer.
Do not prepare NULL objects.
--- drivers/gpu/drm/drm_gpuvm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_gpuvm.c +3 -0
@@ -1322,6 +1322,9 @@ drm_gpuvm_prepare_range(struct drm_gpuvm *gpuvm, struct drm_exec *exec,drm_gpuvm_for_each_va_range (va, gpuvm, addr, end) {struct drm_gem_object *obj = va->gem.obj; +if (unlikely (!obj)) +continue ; + ret =exec_prepare_obj (exec, obj, num_fences);if (ret)return ret;
Signature · 1 line
2.43.0
Hi Jonathan,
Quoted 35 lines · Jonathan Cavitt
Statis analysis issue:
drm_gpuvm_prepare_rangeissues anexec_object_preparecall to alldrm_gem_objectsmapped between addr and addr + range. However, it is possible (albeit very unlikely) that the objects found throughdrm_gpuvm_for_each_va_range(as connected tova->gem) are NULL, as seen in other functions such asdrm_gpuva_linkanddrm_gpuva_unlink_defer.Do not prepare NULL objects.
Fixes 50c1a36f594b ("drm/gpuvm: track/lock/validate external/evicted objects")Signed-off-by Jonathan Cavitt <[email protected]>Cc Matthew Brost <[email protected]>Cc Thomas Hellström <[email protected]>--- drivers/gpu/drm/drm_gpuvm.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/drm_gpuvm.c +3
-0@@ -1322,6 +1322,9 @@ drm_gpuvm_prepare_range(struct drm_gpuvm *gpuvm, struct drm_exec *exec,drm_gpuvm_for_each_va_range (va, gpuvm, addr, end) {struct drm_gem_object *obj = va->gem.obj; +if (unlikely (!obj)) +continue ; + ret =exec_prepare_obj (exec, obj, num_fences);if (ret)return ret;Signature · 1 line
2.43.0
Since there alerady such checks in other functions, as you pointed out above and the change looks sane:
Signature · 2 lines
Best Regards, Krzysztof
Danilo Krummrich
maintainer(Cc: Alice)
Quoted 5 lines · Jonathan Cavitt
Statis analysis issue:
drm_gpuvm_prepare_rangeissues anexec_object_preparecall to alldrm_gem_objectsmapped between addr and addr + range. However, it is possible (albeit very unlikely) that the objects found through
It is not as unlikely as you might think. The documentation of drm_gpuvm_for_each_va_range() explicitly states:
"This iterator does not skip over the &drm_gpuvm's @kernel_alloc_node."
And the kernel_alloc_node does not have a GEM object set. Also, drivers are free to insert VAs that do not have a GEM object set, e.g. when they have the DRM_GPUVA_SPARSE flag set.
Quoted 2 lines
drm_gpuvm_for_each_va_range(as connected tova->gem) are NULL, as seen in other functions such asdrm_gpuva_linkanddrm_gpuva_unlink_defer.
That said, there is a "real" justification, other than "we do the same thing in other functions" that would have been good to put this into the commit message.
The reason I say "would have been" is because this patch has already been applied -- unfortunately without going through the corresponding maintainer (and non-Intel reviewers). I only noticed it by accident as I saw it pop up in drm-misc-next.
No action needed as the code itself is obviously correct, but for the next time, please make sure to send patches to the corresponding maintainers and reviewers.
- Danilo
-----Original Message-----
From: Danilo Krummrich <[email protected]>
Sent: Thursday, April 16, 2026 1:01 PM
To: Cavitt, Jonathan <[email protected]>
Cc: [email protected]; Gupta, Saurabhg <[email protected]>; Zuo, Alex <[email protected]>; Brost, Matthew <[email protected]>; [email protected]; [email protected]; dri-devel <[email protected]>
Subject: Re: [PATCH] drm/gpuvm: Do not prepare NULL objects
Quoted 25 lines
(Cc: Alice)
Quoted 5 lines · Jonathan Cavitt
Statis analysis issue:
drm_gpuvm_prepare_rangeissues anexec_object_preparecall to alldrm_gem_objectsmapped between addr and addr + range. However, it is possible (albeit very unlikely) that the objects found throughIt is not as unlikely as you might think. The documentation of
drm_gpuvm_for_each_va_range()explicitly states:"This iterator does not skip over the &drm_gpuvm's @kernel_alloc_node."
And the
kernel_alloc_nodedoes not have a GEM object set. Also, drivers are free to insert VAs that do not have a GEM object set, e.g. when they have theDRM_GPUVA_SPARSEflag set.Quoted 2 lines
drm_gpuvm_for_each_va_range(as connected tova->gem) are NULL, as seen in other functions such asdrm_gpuva_linkanddrm_gpuva_unlink_defer.That said, there is a "real" justification, other than "we do the same thing in other functions" that would have been good to put this into the commit message.
Quoted 7 lines
The reason I say "would have been" is because this patch has already been applied -- unfortunately without going through the corresponding maintainer (and non-Intel reviewers). I only noticed it by accident as I saw it pop up in drm-misc-next.
No action needed as the code itself is obviously correct, but for the next time, please make sure to send patches to the corresponding maintainers and reviewers.
Question for the future:
Is Lankhorst, Maarten a proper maintainer for this component?
If not, is there a list I can reference to determine who the proper maintainers I should be contacting are?
-Jonathan Cavitt
Quoted 3 lines
- Danilo
Danilo Krummrich
maintainerQuoted 2 lines · Jonathan Cavitt
Question for the future:
Is Lankhorst, Maarten a proper maintainer for this component?
Maarten is one of the drm-misc tree maintainers.
DRM is a bit special in this regard compared to other kernel subsystems, as DRM also allows non-maintainers to push to development trees. Yet, those development trees still need to be run by someone and those people are the tree maintainers.
Additionally, there are people maintaining the individual components, drivers, etc. and those are usually the people with the strongest domain knowledge.
Patches should be sent to both the tree maintainers and the component maintainers.
Quoted 2 lines
If not, is there a list I can reference to determine who the proper maintainers I should be contacting are?
Absolutely, everything is documented in the MAINTAINERS file in the kernel tree.
The best way to figure out who to send patches to is to use ./scripts/get_maintainer.pl. The script should provide you with the full list of all relevant maintainers and reviewers for your patch.
Additionally, it also outputs people who have been involved in the corresponding component and may be worth Cc'ing as well.
If you run it for your patch you should get the output below.
I hope this helps!
- Danilo
--
$ ./scripts/get_maintainer.pl ./20260130_jonathan_cavitt_drm_gpuvm_do_not_prepare_null_objects.mbx Danilo Krummrich <[email protected]> (maintainer:DRM GPUVM,blamed_fixes:1/1=100%) Matthew Brost <[email protected]> (reviewer:DRM GPUVM) "Thomas Hellström" <[email protected]> (reviewer:DRM GPUVM,blamed_fixes:1/1=100%) Alice Ryhl <[email protected]> (reviewer:DRM GPUVM) Maarten Lankhorst <[email protected]> (maintainer:DRM DRIVERS AND MISC GPU PATCHES) Maxime Ripard <[email protected]> (maintainer:DRM DRIVERS AND MISC GPU PATCHES) Thomas Zimmermann <[email protected]> (maintainer:DRM DRIVERS AND MISC GPU PATCHES) David Airlie <[email protected]> (maintainer:DRM DRIVERS) Simona Vetter <[email protected]> (maintainer:DRM DRIVERS) "Christian König" <[email protected]> (blamed_fixes:1/1=100%) Boris Brezillon <[email protected]> (blamed_fixes:1/1=100%) [email protected] (open list:DRM GPUVM) [email protected] (open list) DRM GPUVM status: Supported
Quoted 25 lines · Danilo Krummrich
Quoted 2 lines · Jonathan Cavitt
Question for the future:
Is Lankhorst, Maarten a proper maintainer for this component?Maarten is one of the drm-misc tree maintainers.
DRM is a bit special in this regard compared to other kernel subsystems, as DRM also allows non-maintainers to push to development trees. Yet, those development trees still need to be run by someone and those people are the tree maintainers.
Additionally, there are people maintaining the individual components, drivers, etc. and those are usually the people with the strongest domain knowledge.
Patches should be sent to both the tree maintainers and the component maintainers.
Quoted 2 lines
If not, is there a list I can reference to determine who the proper maintainers I should be contacting are?
Absolutely, everything is documented in the
MAINTAINERSfile in the kernel tree.The best way to figure out who to send patches to is to use
./scripts/get_maintainer.pl. The script should provide you with the full list of all relevant maintainers and reviewers for your patch.
Quoted 6 lines
Additionally, it also outputs people who have been involved in the corresponding component and may be worth Cc'ing as well.
If you run it for your patch you should get the output below.
I hope this helps!
That's a great response! Indeed, the get_maintainer.pl is a good tool to use.
Signature · 2 lines
Regards, Luben