Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Fixes: 0d40d6e399c1 ("staging: erofs: add a generic z_erofs VLE decompressor")
Cc: <stable@vger.kernel.org> # 4.19+
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chao Yu and committed by
Greg Kroah-Hartman
8bce6dce 4420a561

+9 -2
+4
drivers/staging/erofs/unzip_vle.c
··· 1029 1029 1030 1030 skip_allocpage: 1031 1031 vout = erofs_vmap(pages, nr_pages); 1032 + if (!vout) { 1033 + err = -ENOMEM; 1034 + goto out; 1035 + } 1032 1036 1033 1037 err = z_erofs_vle_unzip_vmap(compressed_pages, 1034 1038 clusterpages, vout, llen, work->pageofs, overlapped);
+5 -2
drivers/staging/erofs/unzip_vle_lz4.c
··· 136 136 137 137 nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); 138 138 139 - if (clusterpages == 1) 139 + if (clusterpages == 1) { 140 140 vin = kmap_atomic(compressed_pages[0]); 141 - else 141 + } else { 142 142 vin = erofs_vmap(compressed_pages, clusterpages); 143 + if (!vin) 144 + return -ENOMEM; 145 + } 143 146 144 147 preempt_disable(); 145 148 vout = erofs_pcpubuf[smp_processor_id()].data;