[PATCH 1/3] ceph: check for null dentry in ceph_dir_set_complete()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <elder@xxxxxxxxxxxxx>

---
 fs/ceph/dir.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Index: b/fs/ceph/dir.c
===================================================================
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1115,12 +1115,14 @@ static struct dentry * __d_find_any_alia
 void 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);
+		}
 	}
 }
 


--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux