From: Jeff Layton <jlayton@kernel.org>
To: xiubli@redhat.com
Cc: idryomov@gmail.com, vshankar@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH 1/2] ceph: fix inode reference leakage in ceph_get_snapdir()
Date: Wed, 02 Mar 2022 08:39:27 -0500 [thread overview]
Message-ID: <5cdc302c0e934c079dc23dc01e18be50a078c327.camel@kernel.org> (raw)
In-Reply-To: <20220302085402.64740-2-xiubli@redhat.com>
On Wed, 2022-03-02 at 16:54 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> 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@redhat.com>
> ---
> 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@kernel.org>
next prev parent reply other threads:[~2022-03-02 13:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 8:54 [PATCH 0/2] ceph: misc fixes xiubli
2022-03-02 8:54 ` [PATCH 1/2] ceph: fix inode reference leakage in ceph_get_snapdir() xiubli
2022-03-02 13:39 ` Jeff Layton [this message]
2022-03-02 8:54 ` [PATCH 2/2] ceph: fix a NULL pointer dereference in ceph_handle_caps() xiubli
2022-03-02 14:06 ` Jeff Layton
2022-03-03 1:08 ` Xiubo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cdc302c0e934c079dc23dc01e18be50a078c327.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=vshankar@redhat.com \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox