Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/configfs: free aux. array after storing the wa_bb
@ 2025-11-29 22:25 Michał Grzelak
  2025-11-29 23:02 ` ✗ CI.checkpatch: warning for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Michał Grzelak @ 2025-11-29 22:25 UTC (permalink / raw)
  To: intel-xe
  Cc: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
	Michał Grzelak

When commands issued via configfs are executed mid- or post GPU context
restoration, a temporary buffer is reallocated in order to store all of
commands of varying count. However, after content of the buffer has been
copied to the desired location it is never freed, which causes following
memory leak to appear when running igt@xe_configfs@ctx-restore-mid-bb:

    kmemleak_alloc+0x4a/0x90
    __kmalloc_node_track_caller_noprof+0x645/0x9d0
    krealloc_node_align_noprof+0x206/0x3c0
    wa_bb_store+0xf4/0x2c0 [xe]
    ctx_restore_mid_bb_store+0x21/0x30 [xe]
    configfs_write_iter+0xe6/0x150
    vfs_write+0x231/0x540
    ksys_write+0x6d/0xf0
    __x64_sys_write+0x19/0x30
    x64_sys_call+0x79/0x2350
    do_syscall_64+0x93/0x10f0
    entry_SYSCALL_64_after_hwframe+0x76/0x7e

Deallocate temporary array upon finishing the store of batch buffer
into wa_bb.

Fixes: 39ac06f7006f ("drm/xe/configfs: Add post context restore bb")
Signed-off-by: Michał Grzelak <michal.grzelak@intel.com>
---
 drivers/gpu/drm/xe/xe_configfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
index 9f6251b1008b..f9a64352138b 100644
--- a/drivers/gpu/drm/xe/xe_configfs.c
+++ b/drivers/gpu/drm/xe/xe_configfs.c
@@ -789,6 +789,8 @@ static ssize_t wa_bb_store(struct wa_bb wa_bb[static XE_ENGINE_CLASS_MAX],
 
 	memcpy(wa_bb, tmp_wa_bb, sizeof(tmp_wa_bb));
 
+	kfree(tmp);
+
 	return len;
 }
 
-- 
2.45.2


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

end of thread, other threads:[~2025-12-02 14:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-29 22:25 [PATCH] drm/xe/configfs: free aux. array after storing the wa_bb Michał Grzelak
2025-11-29 23:02 ` ✗ CI.checkpatch: warning for " Patchwork
2025-11-29 23:04 ` ✓ CI.KUnit: success " Patchwork
2025-11-29 23:37 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-30  0:40 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-01 20:25 ` [PATCH] " Rodrigo Vivi
2025-12-02 14:17   ` Michał Grzelak

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