NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>,
	<dan.j.williams@intel.com>
Cc: <vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
	<peterz@infradead.org>, <kjain@linux.ibm.com>, <maddy@in.ibm.com>,
	<nvdimm@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<yusongping@huawei.com>, <artem.kuzin@huawei.com>
Subject: Re: [PATCH] drivers: nvdimm: fix possible memory leak
Date: Fri, 8 Sep 2023 09:36:43 -0700	[thread overview]
Message-ID: <43f5f3db-fe67-eb88-fc36-635d0ff63638@intel.com> (raw)
In-Reply-To: <20230905091507.1672987-1-konstantin.meskhidze@huawei.com>



On 9/5/23 02:15, Konstantin Meskhidze wrote:
> Memory pointed by 'nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs[0]'
> is allocated in function 'nvdimm_pmu_cpu_hotplug_init' via
> 'create_cpumask_attr_group' call. But not released in function
> 'nvdimm_pmu_free_hotplug_memory' or anywhere else before memory pointed by
> 'nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs' will be freed.
> 
> Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose nvdimm performance stats")
> Co-developed-by: Ivanov Mikhail <ivanov.mikhail1@huawei-partners.com>
> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>

Please change subject to something like below. It needs to be a bit more 
descriptive. Thank you!

nvdimm: Fix possible memory leak in nd_perf hotplug release


> ---
>   drivers/nvdimm/nd_perf.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c
> index 2b6dc80d8..ecfa1f635 100644
> --- a/drivers/nvdimm/nd_perf.c
> +++ b/drivers/nvdimm/nd_perf.c
> @@ -264,10 +264,14 @@ static void nvdimm_pmu_free_hotplug_memory(struct nvdimm_pmu *nd_pmu)
>   {
>   	cpuhp_state_remove_instance_nocalls(nd_pmu->cpuhp_state, &nd_pmu->node);
>   	cpuhp_remove_multi_state(nd_pmu->cpuhp_state);
>   
> -	if (nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR])
> +	if (nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]) {
> +		if (nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs)
> +			kfree(nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs[0]);
> +
>   		kfree(nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs);
> +	}
>   	kfree(nd_pmu->pmu.attr_groups[NVDIMM_PMU_CPUMASK_ATTR]);
>   }
>   
>   int register_nvdimm_pmu(struct nvdimm_pmu *nd_pmu, struct platform_device *pdev)

      reply	other threads:[~2023-09-08 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05  9:15 [PATCH] drivers: nvdimm: fix possible memory leak Konstantin Meskhidze
2023-09-08 16:36 ` 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=43f5f3db-fe67-eb88-fc36-635d0ff63638@intel.com \
    --to=dave.jiang@intel.com \
    --cc=artem.kuzin@huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=kjain@linux.ibm.com \
    --cc=konstantin.meskhidze@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maddy@in.ibm.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=vishal.l.verma@intel.com \
    --cc=yusongping@huawei.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 read-only IMAP folder(s) and NNTP newsgroup(s).