[bug report] drm/gpusvm: Add support for GPU Shared Virtual Memory
Dan Carpenter
dan.carpenter at linaro.org
Sat Mar 8 10:28:17 UTC 2025
Hello Matthew Brost,
Commit 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual
Memory") from Mar 5, 2025 (linux-next), leads to the following Smatch
static checker warning:
drivers/gpu/drm/drm_gpusvm.c:794 drm_gpusvm_range_alloc()
error: 'range' dereferencing possible ERR_PTR()
drivers/gpu/drm/drm_gpusvm.c
777 static struct drm_gpusvm_range *
778 drm_gpusvm_range_alloc(struct drm_gpusvm *gpusvm,
779 struct drm_gpusvm_notifier *notifier,
780 unsigned long fault_addr, unsigned long chunk_size,
781 bool migrate_devmem)
782 {
783 struct drm_gpusvm_range *range;
784
785 if (gpusvm->ops->range_alloc)
786 range = gpusvm->ops->range_alloc(gpusvm);
xe_svm_range_alloc() returns ERR_PTR(-ENOMEM).
787 else
788 range = kzalloc(sizeof(*range), GFP_KERNEL);
789
790 if (!range)
791 return ERR_PTR(-ENOMEM);
792
793 kref_init(&range->refcount);
--> 794 range->gpusvm = gpusvm;
^^^^^^^^^^^^^
795 range->notifier = notifier;
796 range->itree.start = ALIGN_DOWN(fault_addr, chunk_size);
797 range->itree.last = ALIGN(fault_addr + 1, chunk_size) - 1;
798 INIT_LIST_HEAD(&range->entry);
799 range->notifier_seq = LONG_MAX;
800 range->flags.migrate_devmem = migrate_devmem ? 1 : 0;
801
802 return range;
803 }
regards,
dan carpenter
More information about the dri-devel
mailing list