[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ada06e3d-598f-4d6d-a468-f007be3f29ca@intel.com>
Date: Fri, 13 Jun 2025 08:56:33 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Li Ming <ming.li@...omail.com>, dave@...olabs.net,
jonathan.cameron@...wei.com, alison.schofield@...el.com,
vishal.l.verma@...el.com, ira.weiny@...el.com, dan.j.williams@...el.com,
shiju.jose@...wei.com
Cc: linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] cxl/edac: Fix potential memory leak issues
On 6/12/25 6:16 PM, Li Ming wrote:
> In cxl_store_rec_gen_media() and cxl_store_rec_dram(), use kmemdup() to
> duplicate a cxl gen_media/dram event to store the event in a xarray by
> xa_store(). The cxl gen_media/dram event allocated by kmemdup() should
> be freed in the case that the xa_store() fails.
>
> Fixes: 0b5ccb0de1e2 ("cxl/edac: Support for finding memory operation attributes from the current boot")
> Signed-off-by: Li Ming <ming.li@...omail.com>
> Tested-by: Shiju Jose <shiju.jose@...wei.com>
> Reviewed-by: Shiju Jose <shiju.jose@...wei.com>
> ---
> v2:
> * Use kfree() instead of __free(kfree). (Jonathan)
>
> base-commit: 87b42c114cdda76c8ad3002f2096699ad5146cb3 cxl/next
Applied to cxl/fixes
In the future, probably best to base against Linus's latest rc rather than cxl/next. Thanks.
> ---
> drivers/cxl/core/edac.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/edac.c b/drivers/cxl/core/edac.c
> index 2cbc664e5d62..628786def464 100644
> --- a/drivers/cxl/core/edac.c
> +++ b/drivers/cxl/core/edac.c
> @@ -1099,8 +1099,10 @@ int cxl_store_rec_gen_media(struct cxl_memdev *cxlmd, union cxl_event *evt)
> old_rec = xa_store(&array_rec->rec_gen_media,
> le64_to_cpu(rec->media_hdr.phys_addr), rec,
> GFP_KERNEL);
> - if (xa_is_err(old_rec))
> + if (xa_is_err(old_rec)) {
> + kfree(rec);
> return xa_err(old_rec);
> + }
>
> kfree(old_rec);
>
> @@ -1127,8 +1129,10 @@ int cxl_store_rec_dram(struct cxl_memdev *cxlmd, union cxl_event *evt)
> old_rec = xa_store(&array_rec->rec_dram,
> le64_to_cpu(rec->media_hdr.phys_addr), rec,
> GFP_KERNEL);
> - if (xa_is_err(old_rec))
> + if (xa_is_err(old_rec)) {
> + kfree(rec);
> return xa_err(old_rec);
> + }
>
> kfree(old_rec);
>
Powered by blists - more mailing lists