All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/reg_sr: Fix leak on xa_store failure
@ 2026-02-03 17:36 Shuicheng Lin
  2026-02-03 18:09 ` ✓ CI.KUnit: success for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Shuicheng Lin @ 2026-02-03 17:36 UTC (permalink / raw)
  To: intel-xe; +Cc: Shuicheng Lin, Matt Roper

Free the newly allocated entry when xa_store() fails to avoid a memory
leak on the error path.

Fixes: e5283bd4dfec ("drm/xe/reg_sr: Remove register pool")
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/xe/xe_reg_sr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_reg_sr.c b/drivers/gpu/drm/xe/xe_reg_sr.c
index d3e13ea33123..ce3dab8a0f47 100644
--- a/drivers/gpu/drm/xe/xe_reg_sr.c
+++ b/drivers/gpu/drm/xe/xe_reg_sr.c
@@ -74,6 +74,7 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
 {
 	unsigned long idx = e->reg.addr;
 	struct xe_reg_sr_entry *pentry = xa_load(&sr->xa, idx);
+	bool allocated = false;
 	int ret;
 
 	if (pentry) {
@@ -94,6 +95,7 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
 		ret = -ENOMEM;
 		goto fail;
 	}
+	allocated = true;
 
 	*pentry = *e;
 	ret = xa_err(xa_store(&sr->xa, idx, pentry, GFP_KERNEL));
@@ -103,6 +105,8 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
 	return 0;
 
 fail:
+	if (allocated)
+		kfree(pentry);
 	xe_gt_err(gt,
 		  "discarding save-restore reg %04lx (clear: %08x, set: %08x, masked: %s, mcr: %s): ret=%d\n",
 		  idx, e->clr_bits, e->set_bits,
-- 
2.50.1


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

end of thread, other threads:[~2026-02-04 18:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 17:36 [PATCH] drm/xe/reg_sr: Fix leak on xa_store failure Shuicheng Lin
2026-02-03 18:09 ` ✓ CI.KUnit: success for " Patchwork
2026-02-03 19:00 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-02-03 23:13 ` ✓ CI.KUnit: success for drm/xe/reg_sr: Fix leak on xa_store failure (rev2) Patchwork
2026-02-03 23:46 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-02-04 13:43 ` ✗ Xe.CI.FULL: " Patchwork
2026-02-04 16:12 ` [PATCH] drm/xe/reg_sr: Fix leak on xa_store failure Vivekanandan, Balasubramani
2026-02-04 17:35   ` Matt Roper
2026-02-04 17:56     ` Lin, Shuicheng
2026-02-04 18:15       ` Matt Roper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.