Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1455813 > unrolled thread

Re: [PATCH] libnvdimm: Fix memory leak in error path.

Started byDan Williams <dan.j.williams@intel.com>
First post2016-08-03 16:20 +0200
Last post2016-08-03 16:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] libnvdimm: Fix memory leak in error path. Dan Williams <dan.j.williams@intel.com> - 2016-08-03 16:20 +0200
    Re: [PATCH] libnvdimm: Fix memory leak in error path. Johannes Thumshirn <jthumshirn@suse.de> - 2016-08-03 16:30 +0200

#1455813 — Re: [PATCH] libnvdimm: Fix memory leak in error path.

FromDan Williams <dan.j.williams@intel.com>
Date2016-08-03 16:20 +0200
SubjectRe: [PATCH] libnvdimm: Fix memory leak in error path.
Message-ID<s25bz-3BD-1@gated-at.bofh.it>
On Wed, Aug 3, 2016 at 7:01 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> If either device_register() or nvdimm_bus_create_ndclt() fails we leak the
> memory allocated for nvdimm_bus. Call kfree(nvdimm_bus) in the error path so
> it's not leaked.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvdimm/core.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
> index be89764..8578365 100644
> --- a/drivers/nvdimm/core.c
> +++ b/drivers/nvdimm/core.c
> @@ -366,6 +366,7 @@ struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
>         return nvdimm_bus;
>   err:
>         put_device(&nvdimm_bus->dev);
> +       kfree(nvdimm_bus);
>         return NULL;
>  }
>  EXPORT_SYMBOL_GPL(__nvdimm_bus_register);
> --

This routine as moved to drivers/nvdimm/bus.c and I don't think this
is valid since device_register() initialize the reference count, and
the call to put_device() will trigger nvdimm_bus_release().

[toc] | [next] | [standalone]


#1455821

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2016-08-03 16:30 +0200
Message-ID<s25lf-3EJ-11@gated-at.bofh.it>
In reply to#1455813
On Wed, Aug 03, 2016 at 07:12:51AM -0700, Dan Williams wrote:
> On Wed, Aug 3, 2016 at 7:01 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> > If either device_register() or nvdimm_bus_create_ndclt() fails we leak the
> > memory allocated for nvdimm_bus. Call kfree(nvdimm_bus) in the error path so
> > it's not leaked.
> >
> > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> > ---
> >  drivers/nvdimm/core.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
> > index be89764..8578365 100644
> > --- a/drivers/nvdimm/core.c
> > +++ b/drivers/nvdimm/core.c
> > @@ -366,6 +366,7 @@ struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
> >         return nvdimm_bus;
> >   err:
> >         put_device(&nvdimm_bus->dev);
> > +       kfree(nvdimm_bus);
> >         return NULL;
> >  }
> >  EXPORT_SYMBOL_GPL(__nvdimm_bus_register);
> > --
> 
> This routine as moved to drivers/nvdimm/bus.c and I don't think this
> is valid since device_register() initialize the reference count, and
> the call to put_device() will trigger nvdimm_bus_release().

Which is correct...

Sorry for the unnecessary patch.

Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web