From: Erez Zadok Date: Sat, 30 Apr 2011 05:34:00 +0000 (-0400) Subject: Unionfs: reorder initializations in ->permission X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=1a9255800914f2f175c6a7a555bbd8657834c0c2;p=unionfs-2.6.39.y.git Unionfs: reorder initializations in ->permission First igrab, then reference the inode in question; and do all this after checking for IPERM_FLAG_RCU. Signed-off-by: Erez Zadok --- diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c index 3d34394306c..21acb882fae 100644 --- a/fs/unionfs/inode.c +++ b/fs/unionfs/inode.c @@ -789,19 +789,23 @@ static int unionfs_permission(struct inode *inode, int mask, unsigned int flags) struct inode *lower_inode = NULL; int err = 0; int bindex, bstart, bend; - const int is_file = !S_ISDIR(inode->i_mode); + int is_file; const int write_mask = (mask & MAY_WRITE) && !(mask & MAY_READ); - struct inode *inode_grabbed = igrab(inode); - struct dentry *dentry = d_find_alias(inode); + struct inode *inode_grabbed; + struct dentry *dentry; if (flags & IPERM_FLAG_RCU) { err = -ECHILD; goto out_nograb; } + dentry = d_find_alias(inode); if (dentry) unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD); + inode_grabbed = igrab(inode); + is_file = !S_ISDIR(inode->i_mode); + if (!UNIONFS_I(inode)->lower_inodes) { if (is_file) /* dirs can be unlinked but chdir'ed to */ err = -ESTALE; /* force revalidate */