Skip to contentSkip to conversation

ntfs: avoid incorrectly release for root inode in fill_super

PATCH NAK Chao Yu 2 participants 3 messages Jul 25, 2014 NTFS filesystem

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 ntfs: avoid incorrectly release for root inode in fill_super

In d_make_root, when we fail to allocate dentry for root inode, we will iput root inode in this function.
So we do not need to release this inode again at d_make_root's caller.

---
 fs/ntfs/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs/super.c +5 -1
index 6c3296e..99c5cc6 100644
@@ -2975,7 +2975,11 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
 			vol->secure_ino = NULL;
 		}
 	}
-	iput(vol->root_ino);
+
+	/*
+	 * Just set NULL value here because we have already iput root_ino
+	 * in d_make_root.
+	 */
 	vol->root_ino = NULL;
 	iput(vol->lcnbmp_ino);
 	vol->lcnbmp_ino = NULL;
Signature · 1 line
2.0.1.474.g72c7794
#1 lore raw

Hi,

NAK

This patch is incorrect. Perhaps you failed to see the ihold() above the d_make_root() call? That means we hold two references on the inode - one from the load_system_files()::ntfs_iget() and one from the ihold() before d_make_root().

Thus in the error code path d_make_root() does iput() which releases one reference and then we do iput() in the error handling path of ntfs_fill_super() which releases the second reference.

Best regards,

Anton

Quoted 26 lines · Chao Yu

In d_make_root, when we fail to allocate dentry for root inode, we will iput root inode in this function.
So we do not need to release this inode again at d_make_root's caller.

---
fs/ntfs/super.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs/super.c +5 -1
index 6c3296e..99c5cc6 100644
@@ -2975,7 +2975,11 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
 			vol->secure_ino = NULL;
 		}
 	}
-	iput(vol->root_ino);
+
+	/*
+	 * Just set NULL value here because we have already iput root_ino
+	 * in d_make_root.
+	 */
 	vol->root_ino = NULL;
 	iput(vol->lcnbmp_ino);
 	vol->lcnbmp_ino = NULL;
Signature · 3 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK
author
#2 lore raw

Hi,

Quoted 9 lines

-----Original Message-----
From: Anton Altaparmakov [mailto:[email protected]] On Behalf Of Anton Altaparmakov
Sent: Friday, July 25, 2014 3:47 PM
To: Chao Yu
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] ntfs: avoid incorrectly release for root inode in fill_super

Hi,

Quoted 8 lines

NAK

This patch is incorrect. Perhaps you failed to see the ihold() above the d_make_root() call? That means we hold two references on the inode - one from the load_system_files()::ntfs_iget() and one from the ihold() before d_make_root().

Thus in the error code path d_make_root() does iput() which releases one reference and then we do iput() in the error handling path of ntfs_fill_super() which releases the second reference.

Yes, you're right. It's my mistaken to missing the code ihold(), sorry about that. Thank you for correcting me, and please ignore this patch.

Quoted 39 lines

Best regards,

Anton

fs/ntfs/super.c static int ntfs_fill_super(struct super_block *sb, void *opt, const

Quoted 14 lines · Chao Yu

In d_make_root, when we fail to allocate dentry for root inode, we will iput root inode in this function.
So we do not need to release this inode again at d_make_root's caller.

---
fs/ntfs/super.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs/super.c +0 -0
index 6c3296e..99c5cc6 100644
@@ -2975,7 +2975,11 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const

int silent)

fs/ntfs/super.c static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) · line 2985

Quoted 12 lines
fs/ntfs/super.c +5 -1
 			vol->secure_ino = NULL;
 		}
 	}
-	iput(vol->root_ino);
+
+	/*
+	 * Just set NULL value here because we have already iput root_ino
+	 * in d_make_root.
+	 */
 	vol->root_ino = NULL;
 	iput(vol->lcnbmp_ino);
 	vol->lcnbmp_ino = NULL;

--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) University of Cambridge Information Services, Roger Needham Building 7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK