Re: [PATCH] devm_memremap_release: fix memremap'd addr handling

From: Toshi Kani
Date: Tue Feb 16 2016 - 19:23:09 EST


On Tue, 2016-02-16 at 16:18 -0800, Andrew Morton wrote:
> On Tue, 16 Feb 2016 09:30:27 -0700 Toshi Kani <toshi.kani@xxxxxxx> wrote:
>
> > The pmem driver calls devm_memremap() to map a persistent memory
> > range.ÂÂWhen the pmem driver is unloaded, this memremap'd range
> > is not released.
> >
> > Fix devm_memremap_release() to handle a given memremap'd address
> > properly.
> >
> > ...
> >
> > --- a/kernel/memremap.c
> > +++ b/kernel/memremap.c
> > @@ -114,7 +114,7 @@ EXPORT_SYMBOL(memunmap);
> > Â
> > Âstatic void devm_memremap_release(struct device *dev, void *res)
> > Â{
> > - memunmap(res);
> > + memunmap(*(void **)res);
> > Â}
> > Â
>
> Huh.ÂÂSo what happens?ÂÂmemunmap() decides it isn't a vmalloc address
> and we leak a vma?

Yes, that's right.

> I'll add a cc:stable to this.

Agreed.

Thanks!
-Toshi