* [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error
[not found] <20250813105121.5945-1-thomas.hellstrom@linux.intel.com>
@ 2025-08-13 10:51 ` Thomas Hellström
2025-08-13 14:45 ` Matthew Brost
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Hellström @ 2025-08-13 10:51 UTC (permalink / raw)
To: intel-xe
Cc: Thomas Hellström, Brian Welty, Rodrigo Vivi, Lucas De Marchi,
stable, Matthew Brost, Joonas Lahtinen, Jani Nikula,
Maarten Lankhorst, Matthew Auld
Avoid triggering a dereference of an error pointer on cleanup in
xe_vm_free_scratch() by clearing any scratch_pt error pointer.
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Fixes: 06951c2ee72d ("drm/xe: Use NULL PTEs as scratch PTEs")
Cc: Brian Welty <brian.welty@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <stable@vger.kernel.org> # v6.8+
---
drivers/gpu/drm/xe/xe_vm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index d40d2d43c041..12e661960244 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1635,8 +1635,12 @@ static int xe_vm_create_scratch(struct xe_device *xe, struct xe_tile *tile,
for (i = MAX_HUGEPTE_LEVEL; i < vm->pt_root[id]->level; i++) {
vm->scratch_pt[id][i] = xe_pt_create(vm, tile, i);
- if (IS_ERR(vm->scratch_pt[id][i]))
- return PTR_ERR(vm->scratch_pt[id][i]);
+ if (IS_ERR(vm->scratch_pt[id][i])) {
+ int err = PTR_ERR(vm->scratch_pt[id][i]);
+
+ vm->scratch_pt[id][i] = NULL;
+ return err;
+ }
xe_pt_populate_empty(tile, vm, vm->scratch_pt[id][i]);
}
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error
2025-08-13 10:51 ` [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error Thomas Hellström
@ 2025-08-13 14:45 ` Matthew Brost
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Brost @ 2025-08-13 14:45 UTC (permalink / raw)
To: Thomas Hellström
Cc: intel-xe, Brian Welty, Rodrigo Vivi, Lucas De Marchi, stable,
Joonas Lahtinen, Jani Nikula, Maarten Lankhorst, Matthew Auld
On Wed, Aug 13, 2025 at 12:51:09PM +0200, Thomas Hellström wrote:
> Avoid triggering a dereference of an error pointer on cleanup in
> xe_vm_free_scratch() by clearing any scratch_pt error pointer.
>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Fixes: 06951c2ee72d ("drm/xe: Use NULL PTEs as scratch PTEs")
> Cc: Brian Welty <brian.welty@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: <stable@vger.kernel.org> # v6.8+
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_vm.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index d40d2d43c041..12e661960244 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -1635,8 +1635,12 @@ static int xe_vm_create_scratch(struct xe_device *xe, struct xe_tile *tile,
>
> for (i = MAX_HUGEPTE_LEVEL; i < vm->pt_root[id]->level; i++) {
> vm->scratch_pt[id][i] = xe_pt_create(vm, tile, i);
> - if (IS_ERR(vm->scratch_pt[id][i]))
> - return PTR_ERR(vm->scratch_pt[id][i]);
> + if (IS_ERR(vm->scratch_pt[id][i])) {
> + int err = PTR_ERR(vm->scratch_pt[id][i]);
> +
> + vm->scratch_pt[id][i] = NULL;
> + return err;
> + }
>
> xe_pt_populate_empty(tile, vm, vm->scratch_pt[id][i]);
> }
> --
> 2.50.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-13 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250813105121.5945-1-thomas.hellstrom@linux.intel.com>
2025-08-13 10:51 ` [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error Thomas Hellström
2025-08-13 14:45 ` Matthew Brost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).