Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm-intel-fixes-2025-12-31' of https://gitlab.freedesktop.org/drm/i915/kernel into drm-fixes

drm/i915 fixes for v6.19-rc4:
- Fix eb_lookup_vmas() failure path

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Jani Nikula <jani.nikula@intel.com>
Link: https://patch.msgid.link/4e79f041395bb8bcc9b2a76bb98b5e3df1c1c3eb@intel.com

+17 -20
+17 -20
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
··· 951 951 vma = eb_lookup_vma(eb, eb->exec[i].handle); 952 952 if (IS_ERR(vma)) { 953 953 err = PTR_ERR(vma); 954 - goto err; 954 + return err; 955 955 } 956 956 957 957 err = eb_validate_vma(eb, &eb->exec[i], vma); 958 958 if (unlikely(err)) { 959 959 i915_vma_put(vma); 960 - goto err; 960 + return err; 961 961 } 962 962 963 963 err = eb_add_vma(eb, &current_batch, i, vma); ··· 966 966 967 967 if (i915_gem_object_is_userptr(vma->obj)) { 968 968 err = i915_gem_object_userptr_submit_init(vma->obj); 969 - if (err) { 970 - if (i + 1 < eb->buffer_count) { 971 - /* 972 - * Execbuffer code expects last vma entry to be NULL, 973 - * since we already initialized this entry, 974 - * set the next value to NULL or we mess up 975 - * cleanup handling. 976 - */ 977 - eb->vma[i + 1].vma = NULL; 978 - } 979 - 969 + if (err) 980 970 return err; 981 - } 982 971 983 972 eb->vma[i].flags |= __EXEC_OBJECT_USERPTR_INIT; 984 973 eb->args->flags |= __EXEC_USERPTR_USED; ··· 975 986 } 976 987 977 988 return 0; 978 - 979 - err: 980 - eb->vma[i].vma = NULL; 981 - return err; 982 989 } 983 990 984 991 static int eb_lock_vmas(struct i915_execbuffer *eb) ··· 3360 3375 3361 3376 eb.exec = exec; 3362 3377 eb.vma = (struct eb_vma *)(exec + args->buffer_count + 1); 3363 - eb.vma[0].vma = NULL; 3378 + memset(eb.vma, 0, (args->buffer_count + 1) * sizeof(struct eb_vma)); 3379 + 3364 3380 eb.batch_pool = NULL; 3365 3381 3366 3382 eb.invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS; ··· 3570 3584 if (err) 3571 3585 return err; 3572 3586 3573 - /* Allocate extra slots for use by the command parser */ 3587 + /* 3588 + * Allocate extra slots for use by the command parser. 3589 + * 3590 + * Note that this allocation handles two different arrays (the 3591 + * exec2_list array, and the eventual eb.vma array introduced in 3592 + * i915_gem_do_execbuffer()), that reside in virtually contiguous 3593 + * memory. Also note that the allocation intentionally doesn't fill the 3594 + * area with zeros, because the exec2_list part doesn't need to be, as 3595 + * it's immediately overwritten by user data a few lines below. 3596 + * However, the eb.vma part is explicitly zeroed later in 3597 + * i915_gem_do_execbuffer(). 3598 + */ 3574 3599 exec2_list = kvmalloc_array(count + 2, eb_element_size(), 3575 3600 __GFP_NOWARN | GFP_KERNEL); 3576 3601 if (exec2_list == NULL) {