Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96d6e3f0 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: fix potential use-after-free issue



In error path of f2fs_read_multi_pages(), it should let last referrer
release decompress io context memory, otherwise, other referrer will
cause use-after-free issue.

Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 8d8b720e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2209,16 +2209,16 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
					page->index, for_write);
			if (IS_ERR(bio)) {
				ret = PTR_ERR(bio);
				bio = NULL;
				dic->failed = true;
				if (refcount_sub_and_test(dic->nr_cpages - i,
							&dic->ref))
							&dic->ref)) {
					f2fs_decompress_end_io(dic->rpages,
							cc->cluster_size, true,
							false);
					f2fs_free_dic(dic);
				}
				f2fs_put_dnode(&dn);
				*bio_ret = bio;
				*bio_ret = NULL;
				return ret;
			}
		}