Skip to content

Commit 3091723

Browse files
ShuichengLinrodrigovivi
authored andcommitted
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: e5283bd ("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: Shuicheng Lin <shuicheng.lin@intel.com> Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patch.msgid.link/20260204172810.1486719-2-shuicheng.lin@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com> (cherry picked from commit 6bc6fec) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 89865e6 commit 3091723

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/xe/xe_reg_sr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
9898
*pentry = *e;
9999
ret = xa_err(xa_store(&sr->xa, idx, pentry, GFP_KERNEL));
100100
if (ret)
101-
goto fail;
101+
goto fail_free;
102102

103103
return 0;
104104

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

0 commit comments

Comments
 (0)