Re: [PATCH] ceph: fix inode leak on getattr error in __fh_to_dentry

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

 



On Fri, Mar 26, 2021 at 11:40:32AM -0400, Jeff Layton wrote:
> Cc: Luis Henriques <lhenriques@xxxxxxx>
> Fixes: 878dabb64117 (ceph: don't return -ESTALE if there's still an open file)
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
>  fs/ceph/export.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/export.c b/fs/ceph/export.c
> index f22156ee7306..17d8c8f4ec89 100644
> --- a/fs/ceph/export.c
> +++ b/fs/ceph/export.c
> @@ -178,8 +178,10 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
>  		return ERR_CAST(inode);
>  	/* We need LINK caps to reliably check i_nlink */
>  	err = ceph_do_getattr(inode, CEPH_CAP_LINK_SHARED, false);
> -	if (err)
> +	if (err) {
> +		iput(inode);

To be honest, I'm failing to see where we could be leaking the inode here.
We're trying to get LINK caps to do the check bellow; if ceph_do_getattr()
fails, the inode reference it (may) grabs will be released by calling
ceph_mdsc_put_request().

Do you see any other possibility?

Cheers,
--
Luís


>  		return ERR_PTR(err);
> +	}
>  	/* -ESTALE if inode as been unlinked and no file is open */
>  	if ((inode->i_nlink == 0) && (atomic_read(&inode->i_count) == 1)) {
>  		iput(inode);
> -- 
> 2.30.2
> 



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux