diff mbox series

[2/2] ceph: fix a NULL pointer dereference in ceph_handle_caps()

Message ID 20220302085402.64740-3-xiubli@redhat.com
State New
Headers show
Series ceph: misc fixes | expand

Commit Message

Xiubo Li March 2, 2022, 8:54 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

The ceph_find_inode() may will fail and return NULL.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/caps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0b36020207fd..0762b55fdbcb 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -4303,7 +4303,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);
 
@@ -4333,6 +4332,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) {