Unverified Commit 30917237 authored by Shuicheng Lin's avatar Shuicheng Lin Committed by Rodrigo Vivi
Browse files

drm/xe/reg_sr: Fix leak on xa_store failure



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

v2: use goto fail_free. (Bala)

Fixes: e5283bd4 ("drm/xe/reg_sr: Remove register pool")
Cc: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: default avatarShuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://patch.msgid.link/20260204172810.1486719-2-shuicheng.lin@intel.com


Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
(cherry picked from commit 6bc6fec7)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 89865e6d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -98,10 +98,12 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
	*pentry = *e;
	ret = xa_err(xa_store(&sr->xa, idx, pentry, GFP_KERNEL));
	if (ret)
		goto fail;
		goto fail_free;

	return 0;

fail_free:
	kfree(pentry);
fail:
	xe_gt_err(gt,
		  "discarding save-restore reg %04lx (clear: %08x, set: %08x, masked: %s, mcr: %s): ret=%d\n",