aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-07-25 14:06:32 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2011-09-06 09:17:14 -0400
commit5441ae5eb3614d3c28f77073370738a2820c88e4 (patch)
treeeb61016b762edb343051e5724527eb1484555085 /fs/9p
parentddf28352b80c86754a6424e3a61e8bdf9213b3c7 (diff)
fs/9p: Add fid before dentry instantiation
d_instantiate marks the dentry positive. So a parallel lookup and mkdir of the directory can find dentry that doesn't have fid attached. This can result in both the code path doing v9fs_fid_add which results in v9fs_dentry leak. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--fs/9p/vfs_inode_dotl.c8
2 files changed, 5 insertions, 7 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 8bb5507e822f..43dd540663af 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -645,13 +645,11 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
645 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); 645 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
646 goto error; 646 goto error;
647 } 647 }
648 d_instantiate(dentry, inode);
649 err = v9fs_fid_add(dentry, fid); 648 err = v9fs_fid_add(dentry, fid);
650 if (err < 0) 649 if (err < 0)
651 goto error; 650 goto error;
652 651 d_instantiate(dentry, inode);
653 return ofid; 652 return ofid;
654
655error: 653error:
656 if (ofid) 654 if (ofid)
657 p9_client_clunk(ofid); 655 p9_client_clunk(ofid);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index b6c8ed205192..0ca224c8bb60 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -281,10 +281,10 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
281 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); 281 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
282 goto error; 282 goto error;
283 } 283 }
284 d_instantiate(dentry, inode);
285 err = v9fs_fid_add(dentry, fid); 284 err = v9fs_fid_add(dentry, fid);
286 if (err < 0) 285 if (err < 0)
287 goto error; 286 goto error;
287 d_instantiate(dentry, inode);
288 288
289 /* Now set the ACL based on the default value */ 289 /* Now set the ACL based on the default value */
290 v9fs_set_create_acl(dentry, &dacl, &pacl); 290 v9fs_set_create_acl(dentry, &dacl, &pacl);
@@ -403,10 +403,10 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
403 err); 403 err);
404 goto error; 404 goto error;
405 } 405 }
406 d_instantiate(dentry, inode);
407 err = v9fs_fid_add(dentry, fid); 406 err = v9fs_fid_add(dentry, fid);
408 if (err < 0) 407 if (err < 0)
409 goto error; 408 goto error;
409 d_instantiate(dentry, inode);
410 fid = NULL; 410 fid = NULL;
411 } else { 411 } else {
412 /* 412 /*
@@ -657,10 +657,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
657 err); 657 err);
658 goto error; 658 goto error;
659 } 659 }
660 d_instantiate(dentry, inode);
661 err = v9fs_fid_add(dentry, fid); 660 err = v9fs_fid_add(dentry, fid);
662 if (err < 0) 661 if (err < 0)
663 goto error; 662 goto error;
663 d_instantiate(dentry, inode);
664 fid = NULL; 664 fid = NULL;
665 } else { 665 } else {
666 /* Not in cached mode. No need to populate inode with stat */ 666 /* Not in cached mode. No need to populate inode with stat */
@@ -810,10 +810,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
810 err); 810 err);
811 goto error; 811 goto error;
812 } 812 }
813 d_instantiate(dentry, inode);
814 err = v9fs_fid_add(dentry, fid); 813 err = v9fs_fid_add(dentry, fid);
815 if (err < 0) 814 if (err < 0)
816 goto error; 815 goto error;
816 d_instantiate(dentry, inode);
817 fid = NULL; 817 fid = NULL;
818 } else { 818 } else {
819 /* 819 /*