]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: put metabuf in error path in fscache mode
authorJingbo Xu <jefflexu@linux.alibaba.com>
Fri, 4 Nov 2022 05:40:27 +0000 (13:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:32 +0000 (09:27 +0100)
[ Upstream commit 75e43355cbe4d5948a79bd592f2ffecb9f75f75d ]

For tail packing layout, put metabuf when error is encountered.

Fixes: 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20221104054028.52208-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/erofs/fscache.c

index 8585e324298c4ebf526692440ef8cc0fc70b913f..79af25f0a56c4525f620680da511bf577ed3a9d7 100644 (file)
@@ -281,8 +281,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
                        return PTR_ERR(src);
 
                iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-               if (copy_to_iter(src + offset, size, &iter) != size)
+               if (copy_to_iter(src + offset, size, &iter) != size) {
+                       erofs_put_metabuf(&buf);
                        return -EFAULT;
+               }
                iov_iter_zero(PAGE_SIZE - size, &iter);
                erofs_put_metabuf(&buf);
                return PAGE_SIZE;