ceph: assign the ci only when the inode isn't NULL
authorXiubo Li <xiubli@redhat.com>
Wed, 2 Mar 2022 07:29:51 +0000 (15:29 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 21 Mar 2022 12:35:16 +0000 (13:35 +0100)
The ceph_find_inode() may will fail and return NULL.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c

index 991c6c8..f1ad688 100644 (file)
@@ -4166,7 +4166,6 @@ void ceph_handle_caps(struct ceph_mds_session *session,
 
        /* lookup ino */
        inode = ceph_find_inode(mdsc->fsc->sb, vino);
-       ci = ceph_inode(inode);
        dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
             vino.snap, inode);
 
@@ -4192,6 +4191,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                }
                goto flush_cap_releases;
        }
+       ci = ceph_inode(inode);
 
        /* these will work even if we don't have a cap yet */
        switch (op) {