提交 c22ee528 编写于 作者: M Miaohe Lin 提交者: Linus Torvalds

mm/vmalloc.c: fix potential memory leak

In VM_MAP_PUT_PAGES case, we should put pages and free array in vfree.
But we missed to set area->nr_pages in vmap().  So we would fail to put
pages in __vunmap() because area->nr_pages = 0.

Link: https://lkml.kernel.org/r/20210107123541.39206-1-linmiaohe@huawei.com
Fixes: b944afc9 ("mm: add a VM_MAP_PUT_PAGES flag for vmap")
Signed-off-by: NShijie Luo <luoshijie1@huawei.com>
Signed-off-by: NMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: NUladzislau Rezki (Sony) <urezki@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 29970dc2
...@@ -2420,8 +2420,10 @@ void *vmap(struct page **pages, unsigned int count, ...@@ -2420,8 +2420,10 @@ void *vmap(struct page **pages, unsigned int count,
return NULL; return NULL;
} }
if (flags & VM_MAP_PUT_PAGES) if (flags & VM_MAP_PUT_PAGES) {
area->pages = pages; area->pages = pages;
area->nr_pages = count;
}
return area->addr; return area->addr;
} }
EXPORT_SYMBOL(vmap); EXPORT_SYMBOL(vmap);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册