* [PATCH] drivers: nvdimm: fix memleak
@ 2023-08-17 11:59 Konstantin Meskhidze
2023-08-17 14:32 ` Jeff Moyer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Konstantin Meskhidze @ 2023-08-17 11:59 UTC (permalink / raw)
To: dan.j.williams
Cc: vishal.l.verma, dave.jiang, ira.weiny, nvdimm, linux-kernel,
yusongping, artem.kuzin
Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function
'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function
'unregister_nvdimm_pmu'.
Co-developed-by: Ivanov Mikhail <ivanov.mikhail1@huawei-partners.com>
Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
---
drivers/nvdimm/nd_perf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c
index 433bbb68a..14881c4e0 100644
--- a/drivers/nvdimm/nd_perf.c
+++ b/drivers/nvdimm/nd_perf.c
@@ -323,7 +323,8 @@ EXPORT_SYMBOL_GPL(register_nvdimm_pmu);
void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu)
{
perf_pmu_unregister(&nd_pmu->pmu);
nvdimm_pmu_free_hotplug_memory(nd_pmu);
+ kfree(nd_pmu->pmu.attr_groups);
kfree(nd_pmu);
}
EXPORT_SYMBOL_GPL(unregister_nvdimm_pmu);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: nvdimm: fix memleak
2023-08-17 11:59 [PATCH] drivers: nvdimm: fix memleak Konstantin Meskhidze
@ 2023-08-17 14:32 ` Jeff Moyer
2023-08-17 15:06 ` Dan Williams
2023-08-17 16:00 ` Dave Jiang
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Moyer @ 2023-08-17 14:32 UTC (permalink / raw)
To: Konstantin Meskhidze
Cc: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny, nvdimm,
linux-kernel, yusongping, artem.kuzin
Konstantin Meskhidze <konstantin.meskhidze@huawei.com> writes:
> Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function
> 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function
> 'unregister_nvdimm_pmu'.
>
> Co-developed-by: Ivanov Mikhail <ivanov.mikhail1@huawei-partners.com>
> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
> ---
> drivers/nvdimm/nd_perf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c
> index 433bbb68a..14881c4e0 100644
> --- a/drivers/nvdimm/nd_perf.c
> +++ b/drivers/nvdimm/nd_perf.c
> @@ -323,7 +323,8 @@ EXPORT_SYMBOL_GPL(register_nvdimm_pmu);
> void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu)
> {
> perf_pmu_unregister(&nd_pmu->pmu);
> nvdimm_pmu_free_hotplug_memory(nd_pmu);
> + kfree(nd_pmu->pmu.attr_groups);
> kfree(nd_pmu);
> }
> EXPORT_SYMBOL_GPL(unregister_nvdimm_pmu);
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drivers: nvdimm: fix memleak
2023-08-17 11:59 [PATCH] drivers: nvdimm: fix memleak Konstantin Meskhidze
2023-08-17 14:32 ` Jeff Moyer
@ 2023-08-17 15:06 ` Dan Williams
2023-08-17 16:00 ` Dave Jiang
2 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2023-08-17 15:06 UTC (permalink / raw)
To: Konstantin Meskhidze, dan.j.williams
Cc: vishal.l.verma, dave.jiang, ira.weiny, nvdimm, linux-kernel,
yusongping, artem.kuzin, kjain, maddy
[ add Kajol and Madhavan ]
Konstantin Meskhidze wrote:
> Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function
> 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function
> 'unregister_nvdimm_pmu'.
Yes, looks like a real issue, but also completely avoidable by using statically
defined groups.
My fault for not catching this earlier, but Kajol, why is nd_perf not using
statically defined sysfs attribute groups?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: nvdimm: fix memleak
2023-08-17 11:59 [PATCH] drivers: nvdimm: fix memleak Konstantin Meskhidze
2023-08-17 14:32 ` Jeff Moyer
2023-08-17 15:06 ` Dan Williams
@ 2023-08-17 16:00 ` Dave Jiang
2 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2023-08-17 16:00 UTC (permalink / raw)
To: Konstantin Meskhidze, dan.j.williams
Cc: vishal.l.verma, ira.weiny, nvdimm, linux-kernel, yusongping,
artem.kuzin
On 8/17/23 04:59, Konstantin Meskhidze wrote:
> Memory pointed by 'nd_pmu->pmu.attr_groups' is allocated in function
> 'register_nvdimm_pmu' and is lost after 'kfree(nd_pmu)' call in function
> 'unregister_nvdimm_pmu'.
>
> Co-developed-by: Ivanov Mikhail <ivanov.mikhail1@huawei-partners.com>
> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
Applied and changed subject to:
nvdimm: Fix memleak of pmu attr_groups in unregister_nvdimm_pmu()
Also added fixes tag:
Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose
nvdimm performance stats")
> ---
> drivers/nvdimm/nd_perf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c
> index 433bbb68a..14881c4e0 100644
> --- a/drivers/nvdimm/nd_perf.c
> +++ b/drivers/nvdimm/nd_perf.c
> @@ -323,7 +323,8 @@ EXPORT_SYMBOL_GPL(register_nvdimm_pmu);
> void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu)
> {
> perf_pmu_unregister(&nd_pmu->pmu);
> nvdimm_pmu_free_hotplug_memory(nd_pmu);
> + kfree(nd_pmu->pmu.attr_groups);
> kfree(nd_pmu);
> }
> EXPORT_SYMBOL_GPL(unregister_nvdimm_pmu);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-17 16:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17 11:59 [PATCH] drivers: nvdimm: fix memleak Konstantin Meskhidze
2023-08-17 14:32 ` Jeff Moyer
2023-08-17 15:06 ` Dan Williams
2023-08-17 16:00 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox