From: Shuicheng Lin <shuicheng.lin@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Shuicheng Lin <shuicheng.lin@intel.com>,
Nitin Gote <nitin.r.gote@intel.com>,
Alexander Usyskin <alexander.usyskin@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Brian Nguyen <brian3.nguyen@intel.com>
Subject: [PATCH 2/2] drm/xe/nvm: Fix double-free on aux add failure
Date: Fri, 16 Jan 2026 21:40:58 +0000 [thread overview]
Message-ID: <20260116214055.2882338-6-shuicheng.lin@intel.com> (raw)
In-Reply-To: <20260116214055.2882338-4-shuicheng.lin@intel.com>
After a successful auxiliary_device_init(), aux_dev->dev.release
(xe_nvm_release_dev()) is responsible for the kfree(nvm). When
there is failure with auxiliary_device_add(), driver will call
auxiliary_device_uninit(), which call put_device(). So that the
.release callback will be triggered to free the memory associated
with the auxiliary_device.
Move the kfree(nvm) into the auxiliary_device_init() failure path
and remove it from the shared err: label to fix below error.
"
[ 13.232905] ==================================================================
[ 13.232911] BUG: KASAN: double-free in xe_nvm_init+0x751/0xf10 [xe]
[ 13.233112] Free of addr ffff888120635000 by task systemd-udevd/273
[ 13.233120] CPU: 8 UID: 0 PID: 273 Comm: systemd-udevd Not tainted 6.19.0-rc2-lgci-xe-kernel+ #225 PREEMPT(voluntary)
...
[ 13.233125] Call Trace:
[ 13.233126] <TASK>
[ 13.233127] dump_stack_lvl+0x7f/0xc0
[ 13.233132] print_report+0xce/0x610
[ 13.233136] ? kasan_complete_mode_report_info+0x5d/0x1e0
[ 13.233139] ? xe_nvm_init+0x751/0xf10 [xe]
...
"
Fixes: d4c3ed963e41 ("drm/xe: defer free of NVM auxiliary container to device release callback")
Cc: Nitin Gote <nitin.r.gote@intel.com>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Suggested-by: Brian Nguyen <brian3.nguyen@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
drivers/gpu/drm/xe/xe_nvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_nvm.c b/drivers/gpu/drm/xe/xe_nvm.c
index 77856f460770..6d18c775d550 100644
--- a/drivers/gpu/drm/xe/xe_nvm.c
+++ b/drivers/gpu/drm/xe/xe_nvm.c
@@ -164,6 +164,7 @@ int xe_nvm_init(struct xe_device *xe)
ret = auxiliary_device_init(aux_dev);
if (ret) {
drm_err(&xe->drm, "xe-nvm aux init failed %d\n", ret);
+ kfree(nvm);
goto err;
}
@@ -176,7 +177,6 @@ int xe_nvm_init(struct xe_device *xe)
return devm_add_action_or_reset(xe->drm.dev, xe_nvm_fini, xe);
err:
- kfree(nvm);
xe->nvm = NULL;
return ret;
}
--
2.50.1
next prev parent reply other threads:[~2026-01-16 21:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 22:00 [PATCH] drm/xe: Manage nvm aux cleanup with devres Shuicheng Lin
2026-01-09 22:14 ` ✓ CI.KUnit: success for " Patchwork
2026-01-09 22:51 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-10 3:27 ` ✓ Xe.CI.Full: " Patchwork
2026-01-13 16:11 ` [PATCH] " Lin, Shuicheng
2026-01-15 11:30 ` Usyskin, Alexander
2026-01-16 18:05 ` Nguyen, Brian3
2026-01-16 18:44 ` Lin, Shuicheng
2026-01-16 21:40 ` [PATCH 0/2] Fix nvm aux resource cleanup Shuicheng Lin
2026-01-16 21:40 ` [PATCH v2 1/2] drm/xe/nvm: Manage nvm aux cleanup with devres Shuicheng Lin
2026-01-16 21:40 ` Shuicheng Lin [this message]
2026-01-17 0:00 ` [PATCH 2/2] drm/xe/nvm: Fix double-free on aux add failure Nguyen, Brian3
2026-01-18 7:03 ` Usyskin, Alexander
2026-01-20 17:42 ` Lin, Shuicheng
2026-01-19 5:15 ` Gote, Nitin R
2026-01-16 21:51 ` ✓ CI.KUnit: success for drm/xe: Manage nvm aux cleanup with devres (rev2) Patchwork
2026-01-16 22:26 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-16 23:45 ` ✓ Xe.CI.Full: " Patchwork
2026-01-20 17:59 ` [PATCH v3 0/3] Fix nvm aux resource cleanup Shuicheng Lin
2026-01-20 17:59 ` [PATCH v3 1/3] drm/xe/nvm: Manage nvm aux cleanup with devres Shuicheng Lin
2026-01-20 17:59 ` [PATCH v3 2/3] drm/xe/nvm: Fix double-free on aux add failure Shuicheng Lin
2026-01-20 17:59 ` [PATCH v3 3/3] drm/xe/nvm: Defer xe->nvm assignment until init succeeds Shuicheng Lin
2026-01-20 18:28 ` [PATCH v4 0/3] Fix nvm aux resource cleanup Shuicheng Lin
2026-01-20 18:28 ` [PATCH v4 1/3] drm/xe/nvm: Manage nvm aux cleanup with devres Shuicheng Lin
2026-01-20 18:28 ` [PATCH v4 2/3] drm/xe/nvm: Fix double-free on aux add failure Shuicheng Lin
2026-01-20 18:28 ` [PATCH v4 3/3] drm/xe/nvm: Defer xe->nvm assignment until init succeeds Shuicheng Lin
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=20260116214055.2882338-6-shuicheng.lin@intel.com \
--to=shuicheng.lin@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=brian3.nguyen@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=nitin.r.gote@intel.com \
--cc=rodrigo.vivi@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