提交 a090ed15 编写于 作者: C Chao Yu 提交者: Greg Kroah-Hartman

staging: erofs: fix to handle error path of erofs_vmap()

commit 8bce6dcede65139a087ff240127e3f3c01363eed upstream.

erofs_vmap() wrapped vmap() and vm_map_ram() to return virtual
continuous memory, but both of them can failed due to a lot of
reason, previously, erofs_vmap()'s callers didn't handle them,
which can potentially cause NULL pointer access, fix it.

Fixes: 3883a79a ("staging: erofs: introduce VLE decompression support")
Fixes: 0d40d6e3 ("staging: erofs: add a generic z_erofs VLE decompressor")
Cc: <stable@vger.kernel.org> # 4.19+
Signed-off-by: NGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: NChao Yu <yuchao0@huawei.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 3b6b7664
...@@ -942,6 +942,10 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -942,6 +942,10 @@ static int z_erofs_vle_unzip(struct super_block *sb,
skip_allocpage: skip_allocpage:
vout = erofs_vmap(pages, nr_pages); vout = erofs_vmap(pages, nr_pages);
if (!vout) {
err = -ENOMEM;
goto out;
}
err = z_erofs_vle_unzip_vmap(compressed_pages, err = z_erofs_vle_unzip_vmap(compressed_pages,
clusterpages, vout, llen, work->pageofs, overlapped); clusterpages, vout, llen, work->pageofs, overlapped);
......
...@@ -116,10 +116,13 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, ...@@ -116,10 +116,13 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE);
if (clusterpages == 1) if (clusterpages == 1) {
vin = kmap_atomic(compressed_pages[0]); vin = kmap_atomic(compressed_pages[0]);
else } else {
vin = erofs_vmap(compressed_pages, clusterpages); vin = erofs_vmap(compressed_pages, clusterpages);
if (!vin)
return -ENOMEM;
}
preempt_disable(); preempt_disable();
vout = erofs_pcpubuf[smp_processor_id()].data; vout = erofs_pcpubuf[smp_processor_id()].data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册