]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl/region: Fix leakage in __construct_region()
authorDavidlohr Bueso <dave@stgolabs.net>
Mon, 2 Feb 2026 19:13:30 +0000 (11:13 -0800)
committerDave Jiang <dave.jiang@intel.com>
Wed, 4 Mar 2026 17:26:39 +0000 (10:26 -0700)
Failing the first sysfs_update_group() needs to explicitly
kfree the resource as it is too early for cxl_region_iomem_release()
to do so.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Gregory Price <gourry@gourry.net>
Fixes: d6602e25819d (cxl/region: Add support to indicate region has extended linear cache)
Link: https://patch.msgid.link/20260202191330.245608-1-dave@stgolabs.net
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/region.c

index 42874948b589b95a498230a93f5951f30317c0eb..c37ae0b28bbbc90320a7bf1c16bf412bad2783ca 100644 (file)
@@ -3854,8 +3854,10 @@ static int __construct_region(struct cxl_region *cxlr,
        }
 
        rc = sysfs_update_group(&cxlr->dev.kobj, &cxl_region_group);
-       if (rc)
+       if (rc) {
+               kfree(res);
                return rc;
+       }
 
        rc = insert_resource(cxlrd->res, res);
        if (rc) {