ceph: fix dentry leaks
authorYan, Zheng <zyan@redhat.com>
Mon, 2 Feb 2015 03:27:56 +0000 (11:27 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 19 Feb 2015 10:31:40 +0000 (13:31 +0300)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/dir.c
fs/ceph/inode.c

index 709f3b9..77eeb76 100644 (file)
@@ -676,6 +676,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
                 */
                BUG_ON(!result->d_inode);
                d_instantiate(dentry, result->d_inode);
+               d_drop(result);
                return 0;
        }
        return PTR_ERR(result);
index f88a0f0..be3af18 100644 (file)
@@ -1449,12 +1449,14 @@ retry_lookup:
                }
 
                if (!dn->d_inode) {
-                       dn = splice_dentry(dn, in, NULL);
-                       if (IS_ERR(dn)) {
-                               err = PTR_ERR(dn);
+                       struct dentry *realdn = splice_dentry(dn, in, NULL);
+                       if (IS_ERR(realdn)) {
+                               err = PTR_ERR(realdn);
+                               d_drop(dn);
                                dn = NULL;
                                goto next_item;
                        }
+                       dn = realdn;
                }
 
                di = dn->d_fsdata;