]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/reg_sr: Fix leak on xa_store failure
authorShuicheng Lin <shuicheng.lin@intel.com>
Wed, 4 Feb 2026 17:28:11 +0000 (17:28 +0000)
committerMatt Roper <matthew.d.roper@intel.com>
Mon, 2 Mar 2026 22:29:29 +0000 (14:29 -0800)
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: e5283bd4dfec ("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>
drivers/gpu/drm/xe/xe_reg_sr.c

index 83a668f2a0d5f16ea3f0b93eafb6b8e66abe3fe8..7d377f20f84e6cdf05bd5f62302629bf11d13f3f 100644 (file)
@@ -100,10 +100,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",