Re: [PATCH 07/11] gfs2: pass correct dentry to finish_open() in __gfs2_lookup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 2013-09-16 at 15:34 +0200, Miklos Szeredi wrote:
> On Mon, Sep 16, 2013 at 02:13:14PM +0100, Steven Whitehouse wrote:
> > Hi,
> > 
> > On Mon, 2013-09-16 at 14:52 +0200, Miklos Szeredi wrote:
> > > From: Miklos Szeredi <mszeredi@xxxxxxx>
> > > 
> > > AFAICS if d_splice_alias() returned non-NULL, this code would Oops
> > > (finish_open expects an instantiated dentry).
> > > 
> > > Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
> > > Cc: Steven Whitehouse <swhiteho@xxxxxxxxxx>
> > > Cc: stable@xxxxxxxxxxxxxxx
> > > ---
> > >  fs/gfs2/inode.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> > > index 6d7f976..abe7dae 100644
> > > --- a/fs/gfs2/inode.c
> > > +++ b/fs/gfs2/inode.c
> > > @@ -774,7 +774,7 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
> > >  
> > >  	d = d_splice_alias(inode, dentry);
> > >  	if (file && S_ISREG(inode->i_mode))
> > > -		error = finish_open(file, dentry, gfs2_open_common, opened);
> > > +		error = finish_open(file, d ? d : dentry, gfs2_open_common, opened);
> > >  
> > >  	gfs2_glock_dq_uninit(&gh);
> > >  	if (error)
> > 
> > Not sure I understand why this is required... when the inode is a
> > regular file, d can only be an error (if the inode is an error) or it
> > will be NULL.
> 
> Okay, you're right.  Still, something like the following should make this clear
> and ensure things don't break in the future.
> 
or better still, just add a comment to explain the situation as the
reader may still be wondering why that BUG_ON() will never trigger,

Steve.

> Thanks,
> Miklos
> 
> ---
>  fs/gfs2/inode.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -775,8 +775,10 @@ static struct dentry *__gfs2_lookup(stru
>  	}
>  
>  	d = d_splice_alias(inode, dentry);
> -	if (file && S_ISREG(inode->i_mode))
> +	if (file && S_ISREG(inode->i_mode)) {
> +		BUG_ON(d);
>  		error = finish_open(file, dentry, gfs2_open_common, opened);
> +	}
>  
>  	gfs2_glock_dq_uninit(&gh);
>  	if (error)


--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]