Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Grzelak" <michal.grzelak@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Lucas De Marchi" <demarchi@kernel.org>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Michał Grzelak" <michal.grzelak@intel.com>
Subject: [PATCH] drm/xe/configfs: free aux. array after storing the wa_bb
Date: Sat, 29 Nov 2025 23:25:41 +0100	[thread overview]
Message-ID: <20251129222541.3306090-1-michal.grzelak@intel.com> (raw)

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


             reply	other threads:[~2025-11-29 22:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-29 22:25 Michał Grzelak [this message]
2025-11-29 23:02 ` ✗ CI.checkpatch: warning for drm/xe/configfs: free aux. array after storing the wa_bb 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251129222541.3306090-1-michal.grzelak@intel.com \
    --to=michal.grzelak@intel.com \
    --cc=demarchi@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox