public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev][PATCH] f2fs: fix error path in init_inode_metadata
@ 2014-06-24  2:34 Chao Yu
  0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2014-06-24  2:34 UTC (permalink / raw)
  To: Jaegeuk Kim, Changman Lee; +Cc: linux-f2fs-devel, linux-fsdevel, linux-kernel

If we fail in this path:
->init_inode_metadata
  ->make_empty_dir
    ->get_new_data_page
      ->grab_cache_page return -ENOMEM

We will bug on in error path of init_inode_metadata when call remove_inode_page
because i_block = 2 (one inode block will be released later & one dentry block).

We should release the dentry block in init_inode_metadata to avoid this BUG_ON,
and avoid leak of dentry block resource, because we never have second chance to
release that block in ->evict_inode as in upper error path we make this inode
'bad'.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 09760d5..3677f41 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -384,11 +384,11 @@ static struct page *init_inode_metadata(struct inode *inode,
 
 put_error:
 	f2fs_put_page(page, 1);
+error:
 	/* once the failed inode becomes a bad inode, i_mode is S_IFREG */
 	truncate_inode_pages(&inode->i_data, 0);
 	truncate_blocks(inode, 0);
 	remove_dirty_dir_inode(inode);
-error:
 	remove_inode_page(inode);
 	return ERR_PTR(err);
 }
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-24  2:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-24  2:34 [f2fs-dev][PATCH] f2fs: fix error path in init_inode_metadata Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox