On Wed, 2022-03-02 at 16:54 +0800, xiubli@xxxxxxxxxx wrote: > From: Xiubo Li <xiubli@xxxxxxxxxx> > > The ceph_get_inode() will search for or insert a new inode into the > hash for the given vino, and return a reference to it. If new is > non-NULL, its reference is consumed. > > We should release the reference when in error handing cases. > > Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx> > --- > fs/ceph/inode.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > index 8b0832271fdf..cbeba8a93a07 100644 > --- a/fs/ceph/inode.c > +++ b/fs/ceph/inode.c > @@ -164,13 +164,13 @@ struct inode *ceph_get_snapdir(struct inode *parent) > if (!S_ISDIR(parent->i_mode)) { > pr_warn_once("bad snapdir parent type (mode=0%o)\n", > parent->i_mode); > - return ERR_PTR(-ENOTDIR); > + goto err; > } > > if (!(inode->i_state & I_NEW) && !S_ISDIR(inode->i_mode)) { > pr_warn_once("bad snapdir inode type (mode=0%o)\n", > inode->i_mode); > - return ERR_PTR(-ENOTDIR); > + goto err; > } > > inode->i_mode = parent->i_mode; > @@ -190,6 +190,12 @@ struct inode *ceph_get_snapdir(struct inode *parent) > } > > return inode; > +err: > + if ((inode->i_state & I_NEW)) > + discard_new_inode(inode); > + else > + iput(inode); > + return ERR_PTR(-ENOTDIR); > } > > const struct inode_operations ceph_file_iops = { Good catch! Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>