Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/i915: Use symmetric free for vma resources
@ 2025-11-18 14:01 Andi Shyti
  2025-11-18 17:00 ` ✓ i915.CI.BAT: success for drm/i915: Use symmetric free for vma resources (rev2) Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andi Shyti @ 2025-11-18 14:01 UTC (permalink / raw)
  To: intel-gfx, dri-devel; +Cc: Andi Shyti, Zilin Guan, Krzysztof Karas, Andi Shyti

From: Zilin Guan <zilin@seu.edu.cn>

The error paths in reserve_gtt_with_resource() and
insert_gtt_with_resource() use kfree() to release a vma_res object
that was allocated with i915_vma_resource_alloc().

While kfree() can handle slab-allocated objects, it is better practice
to use the symmetric free function.

Replace kfree() with the specific i915_vma_resource_free() helper to
improve readability and ensure the alloc/free pairing is explicit.

Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20251113063405.116845-1-zilin@seu.edu.cn
---
Hi,

I'm resending this patch so that CI takes it and tests it

Changes in v3 (from Andi):
- Added my SoB and r-b tag.

Changes in v2 (from Zilin):
- Reword commit message to describe this as a readability change.
- Drop the Fixes tag.

 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 0a86e4857539..e9df4b9f5ebe 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -1528,7 +1528,7 @@ static int reserve_gtt_with_resource(struct i915_vma *vma, u64 offset)
 		i915_vma_resource_init_from_vma(vma_res, vma);
 		vma->resource = vma_res;
 	} else {
-		kfree(vma_res);
+		i915_vma_resource_free(vma_res);
 	}
 	mutex_unlock(&vm->mutex);
 
@@ -1708,7 +1708,7 @@ static int insert_gtt_with_resource(struct i915_vma *vma)
 		i915_vma_resource_init_from_vma(vma_res, vma);
 		vma->resource = vma_res;
 	} else {
-		kfree(vma_res);
+		i915_vma_resource_free(vma_res);
 	}
 	mutex_unlock(&vm->mutex);
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-19 16:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 14:01 [PATCH v3] drm/i915: Use symmetric free for vma resources Andi Shyti
2025-11-18 17:00 ` ✓ i915.CI.BAT: success for drm/i915: Use symmetric free for vma resources (rev2) Patchwork
2025-11-18 21:43 ` ✗ i915.CI.Full: failure " Patchwork
2025-11-19 14:24 ` ✓ i915.CI.BAT: success for drm/i915: Use symmetric free for vma resources (rev3) Patchwork
2025-11-19 16:57 ` ✓ i915.CI.Full: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox