Skip to content

Commit 9e3fc1d

Browse files
matt-auldThomas Hellström
authored andcommitted
drm/xe/vm: don't ignore error when in_kthread
If GUP fails and we are in_kthread, we can have pinned = 0 and ret = 0. If that happens we call sg_alloc_append_table_from_pages() with n_pages = 0, which is not well behaved and can trigger: kernel BUG at include/linux/scatterlist.h:115! depending on if the pages array happens to be zeroed or not. Even if we don't hit that it crashes later when trying to dma_map the returned table. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240202171435.427630-2-matthew.auld@intel.com (cherry picked from commit 8087199) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 95c058c commit 9e3fc1d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,8 @@ int xe_vma_userptr_pin_pages(struct xe_userptr_vma *uvma)
114114
num_pages - pinned,
115115
read_only ? 0 : FOLL_WRITE,
116116
&pages[pinned]);
117-
if (ret < 0) {
118-
if (in_kthread)
119-
ret = 0;
117+
if (ret < 0)
120118
break;
121-
}
122119

123120
pinned += ret;
124121
ret = 0;

0 commit comments

Comments
 (0)