diff options
author | Chao Yu <yuchao0@huawei.com> | 2020-03-02 12:34:27 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-03-10 19:18:33 +0300 |
commit | 06c7540fd29ccae351d1a9e0a0a817cb235618bd (patch) | |
tree | 71238c471f13b7dbf5c82820ca71252eee9b1710 /fs | |
parent | 7a88ddb56077d07257a5d0393a4be13e424ca755 (diff) | |
download | linux-06c7540fd29ccae351d1a9e0a0a817cb235618bd.tar.xz |
f2fs: fix to avoid using uninitialized variable
In f2fs_vm_page_mkwrite(), if inode is compress one, and current mmapped
page locates in compressed cluster, we have to call f2fs_get_dnode_of_data()
to get its physical block address before f2fs_wait_on_block_writeback().
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/file.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 8c725111840e..b443dc2947c7 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -106,10 +106,18 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) err = f2fs_get_block(&dn, page->index); f2fs_put_dnode(&dn); __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); - if (err) { - unlock_page(page); - goto out_sem; - } + } + +#ifdef CONFIG_F2FS_FS_COMPRESSION + if (!need_alloc) { + set_new_dnode(&dn, inode, NULL, NULL, 0); + err = f2fs_get_dnode_of_data(&dn, page->index, LOOKUP_NODE); + f2fs_put_dnode(&dn); + } +#endif + if (err) { + unlock_page(page); + goto out_sem; } f2fs_wait_on_page_writeback(page, DATA, false, true); |