linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Li Ming <ming.li@zohomail.com>,
	dave@stgolabs.net, jonathan.cameron@huawei.com,
	alison.schofield@intel.com, vishal.l.verma@intel.com,
	ira.weiny@intel.com, dan.j.williams@intel.com,
	shiju.jose@huawei.com
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] cxl/edac: Fix potential memory leak issues
Date: Fri, 13 Jun 2025 08:56:33 -0700	[thread overview]
Message-ID: <ada06e3d-598f-4d6d-a468-f007be3f29ca@intel.com> (raw)
In-Reply-To: <20250613011648.102840-1-ming.li@zohomail.com>



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@zohomail.com>
> Tested-by: Shiju Jose <shiju.jose@huawei.com>
> Reviewed-by: Shiju Jose <shiju.jose@huawei.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);
>  


      parent reply	other threads:[~2025-06-13 15:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13  1:16 [PATCH v2 1/1] cxl/edac: Fix potential memory leak issues Li Ming
2025-06-13 10:33 ` Jonathan Cameron
2025-06-13 14:30 ` Ira Weiny
2025-06-13 14:30 ` Ira Weiny
2025-06-13 15:56 ` Dave Jiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ada06e3d-598f-4d6d-a468-f007be3f29ca@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=shiju.jose@huawei.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).