ceph: check for null dentry in ceph_dir_set_complete()
PATCH 1/3 ceph: check for null dentry in ceph_dir_set_complete()
In ceph_dir_set_complete(), the return value of __d_find_any_alias() is blindly dereferenced. That function can return a null pointer, so the dereference needs to be protected by a check for that.
Signed-off-by Alex Elder <[email protected]>
--- fs/ceph/dir.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ceph/dir.c +7 -5
@@ -1115,12 +1115,14 @@ static struct dentry * __d_find_any_aliavoid ceph_dir_set_complete (struct inode *inode) {struct dentry *dentry =__d_find_any_alias (inode); -struct ceph_fs_client *fsc =ceph_sb_to_client (dentry->d_sb); -if (dentry &&ceph_dentry (dentry) && -ceph_test_mount_opt (fsc,USEDCACHE )) { -dout (" marking %p (%p) complete\n" , inode, dentry); -set_bit (CEPH_D_COMPLETE , &ceph_dentry (dentry)->flags); +if (dentry &&ceph_dentry (dentry)) { +struct ceph_fs_client *fsc =ceph_sb_to_client (dentry->d_sb); + +if (ceph_test_mount_opt (fsc,USEDCACHE )) { +dout (" marking %p (%p) complete\n" , inode, dentry); +set_bit (CEPH_D_COMPLETE , &ceph_dentry (dentry)->flags); + } } }