mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ntfs: avoid incorrectly release for root inode in fill_super
@ 2014-07-25  2:25 Chao Yu
  2014-07-25  7:47 ` Anton Altaparmakov
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2014-07-25  2:25 UTC (permalink / raw)
  To: anton; +Cc: linux-ntfs-dev, linux-kernel

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.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/ntfs/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c3296e..99c5cc6 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -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;
-- 
2.0.1.474.g72c7794



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ntfs: avoid incorrectly release for root inode in fill_super
  2014-07-25  2:25 [PATCH] ntfs: avoid incorrectly release for root inode in fill_super Chao Yu
@ 2014-07-25  7:47 ` Anton Altaparmakov
  2014-07-25  8:54   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Altaparmakov @ 2014-07-25  7:47 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-ntfs-dev, linux-kernel

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

On 25 Jul 2014, at 03:25, Chao Yu <chao2.yu@samsung.com> wrote:

> 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.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> fs/ntfs/super.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 6c3296e..99c5cc6 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -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;

-- 
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] ntfs: avoid incorrectly release for root inode in fill_super
  2014-07-25  7:47 ` Anton Altaparmakov
@ 2014-07-25  8:54   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2014-07-25  8:54 UTC (permalink / raw)
  To: 'Anton Altaparmakov'
  Cc: linux-ntfs-dev, linux-kernel, 'Anton Altaparmakov'

Hi,

> -----Original Message-----
> From: Anton Altaparmakov [mailto:aia21@hermes.cam.ac.uk] On Behalf Of Anton Altaparmakov
> Sent: Friday, July 25, 2014 3:47 PM
> To: Chao Yu
> Cc: linux-ntfs-dev@lists.sourceforge.net; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] ntfs: avoid incorrectly release for root inode in fill_super
> 
> 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.

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.

> 
> Best regards,
> 
> 	Anton
> 
> On 25 Jul 2014, at 03:25, Chao Yu <chao2.yu@samsung.com> wrote:
> 
> > 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.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> > fs/ntfs/super.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> > index 6c3296e..99c5cc6 100644
> > --- a/fs/ntfs/super.c
> > +++ b/fs/ntfs/super.c
> > @@ -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;
> 
> --
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-25  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25  2:25 [PATCH] ntfs: avoid incorrectly release for root inode in fill_super Chao Yu
2014-07-25  7:47 ` Anton Altaparmakov
2014-07-25  8:54   ` Chao Yu

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

all inboxes | Powered by JetHome®