Message ID | 151756015373.24501.12460100041032944306.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
This fix will not work, as daxctl_ctx is freed before free_dax() and daxctl_region_unref() tries to update daxctl_ctx. > -----Original Message----- > From: Linux-nvdimm [mailto:linux-nvdimm-bounces@lists.01.org] On Behalf > Of Dan Williams > Sent: Friday, February 2, 2018 09:29 > To: linux-nvdimm@lists.01.org > Subject: [ndctl PATCH] ndctl: fix leak of daxctl_region instances > > The daxctl_region returned by ndctl_dax_get_daxctl_region() should be > automatically freed when its parent infrastructure is torn down. > > Reported-by: Lukasz Plewa <lukasz.plewa@intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > ndctl/lib/libndctl.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index > 4119a2e6b564..9314e8b8f81b 100644 > --- a/ndctl/lib/libndctl.c > +++ b/ndctl/lib/libndctl.c > @@ -434,6 +434,7 @@ static void free_pfn(struct ndctl_pfn *pfn, struct > list_head *head) > > static void free_dax(struct ndctl_dax *dax, struct list_head *head) { > + daxctl_region_unref(dax->region); > __free_pfn(&dax->pfn, head, dax); > } > > > _______________________________________________ > Linux-nvdimm mailing list > Linux-nvdimm@lists.01.org > https://lists.01.org/mailman/listinfo/linux-nvdimm
On Fri, Feb 2, 2018 at 7:15 AM, Plewa, Lukasz <lukasz.plewa@intel.com> wrote:
> This fix will not work, as daxctl_ctx is freed before free_dax() and daxctl_region_unref() tries to update daxctl_ctx.
Ah true, we need to take and hold another daxctl_ctx reference for
each daxctl_region and unref the daxctl_ctx for each daxctl_region.
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 4119a2e6b564..9314e8b8f81b 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -434,6 +434,7 @@ static void free_pfn(struct ndctl_pfn *pfn, struct list_head *head) static void free_dax(struct ndctl_dax *dax, struct list_head *head) { + daxctl_region_unref(dax->region); __free_pfn(&dax->pfn, head, dax); }
The daxctl_region returned by ndctl_dax_get_daxctl_region() should be automatically freed when its parent infrastructure is torn down. Reported-by: Lukasz Plewa <lukasz.plewa@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- ndctl/lib/libndctl.c | 1 + 1 file changed, 1 insertion(+)