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 709f3b98ca5cde7fbcf4f2d14a2299cf87e7633d..77eeb768f95acb56d3fced3839cdf1d37bd1ec8a 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 f88a0f059dc8e24f677755c03905dba659181e03..be3af18e4cf1369196c56179f855b93081cf1a92 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;