Skip to content

Commit 9106713

Browse files
Thomas Hellströmrodrigovivi
authored andcommitted
drm/xe/userptr: Fix an incorrect assert
The assert incorrectly checks the total length processed which can in fact be greater than the number of pages. Fix. Fixes: 0a98219 ("drm/xe/hmm: Don't dereference struct page pointers without notifier lock") Cc: Matthew Auld <matthew.auld@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250307100109.21397-1-thomas.hellstrom@linux.intel.com (cherry picked from commit 70e5043) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 10c7988 commit 9106713

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpu/drm/xe/xe_hmm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,17 @@ static int xe_build_sg(struct xe_device *xe, struct hmm_range *range,
138138
i += size;
139139

140140
if (unlikely(j == st->nents - 1)) {
141+
xe_assert(xe, i >= npages);
141142
if (i > npages)
142143
size -= (i - npages);
144+
143145
sg_mark_end(sgl);
146+
} else {
147+
xe_assert(xe, i < npages);
144148
}
149+
145150
sg_set_page(sgl, page, size << PAGE_SHIFT, 0);
146151
}
147-
xe_assert(xe, i == npages);
148152

149153
return dma_map_sgtable(dev, st, write ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE,
150154
DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_NO_KERNEL_MAPPING);

0 commit comments

Comments
 (0)