f2fs: report error for f2fs_parent_dir
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 9 Jun 2016 21:57:19 +0000 (14:57 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 6 Jul 2016 17:44:06 +0000 (10:44 -0700)
If there is no dentry, we can report its error correctly.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/namei.c

index 78efe00a3a2fe0617d19deb9ff0cd6180ef4e795..618829e8049c09de846972a5438e92fca19dbcc9 100644 (file)
@@ -662,10 +662,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                goto out;
 
        if (S_ISDIR(old_inode->i_mode)) {
-               err = -EIO;
                old_dir_entry = f2fs_parent_dir(old_inode, &old_dir_page);
-               if (!old_dir_entry)
+               if (!old_dir_entry) {
+                       err = PTR_ERR(old_dir_page);
                        goto out_old;
+               }
        }
 
        if (flags & RENAME_WHITEOUT) {
@@ -838,19 +839,21 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
        /* prepare for updating ".." directory entry info later */
        if (old_dir != new_dir) {
                if (S_ISDIR(old_inode->i_mode)) {
-                       err = -EIO;
                        old_dir_entry = f2fs_parent_dir(old_inode,
                                                        &old_dir_page);
-                       if (!old_dir_entry)
+                       if (!old_dir_entry) {
+                               err = PTR_ERR(old_dir_page);
                                goto out_new;
+                       }
                }
 
                if (S_ISDIR(new_inode->i_mode)) {
-                       err = -EIO;
                        new_dir_entry = f2fs_parent_dir(new_inode,
                                                        &new_dir_page);
-                       if (!new_dir_entry)
+                       if (!new_dir_entry) {
+                               err = PTR_ERR(new_dir_page);
                                goto out_old_dir;
+                       }
                }
        }