f2fs: fix to verify tpage before releasing in f2fs_free_dic()
authorChao Yu <yuchao0@huawei.com>
Thu, 26 Mar 2020 09:42:26 +0000 (17:42 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 3 Apr 2020 17:21:31 +0000 (10:21 -0700)
In below error path, tpages[i] could be NULL, fix to check it before
releasing it.
- f2fs_read_multi_pages
 - f2fs_alloc_dic
  - f2fs_free_dic

Fixes: 61fbae2b2b12 ("f2fs: fix to avoid NULL pointer dereference")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c

index ca4f54f..df7b2d1 100644 (file)
@@ -1333,6 +1333,8 @@ void f2fs_free_dic(struct decompress_io_ctx *dic)
                for (i = 0; i < dic->cluster_size; i++) {
                        if (dic->rpages[i])
                                continue;
+                       if (!dic->tpages[i])
+                               continue;
                        unlock_page(dic->tpages[i]);
                        put_page(dic->tpages[i]);
                }