Skip to content

Commit

Permalink
Introduce path_put()
Browse files Browse the repository at this point in the history
* Add path_put() functions for releasing a reference to the dentry and
  vfsmount of a struct path in the right order

* Switch from path_release(nd) to path_put(&nd->path)

* Rename dput_path() to path_put_conditional()

[[email protected]: fix cifs]
Signed-off-by: Jan Blunck <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
Cc: <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Steven French <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jan Blunck authored and Linus Torvalds committed Feb 15, 2008
1 parent 4ac9137 commit 1d957f9
Show file tree
Hide file tree
Showing 41 changed files with 125 additions and 118 deletions.
2 changes: 1 addition & 1 deletion arch/alpha/kernel/osf_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ osf_statfs(char __user *path, struct osf_statfs __user *buffer, unsigned long bu
retval = user_path_walk(path, &nd);
if (!retval) {
retval = do_osf_statfs(nd.path.dentry, buffer, bufsiz);
path_release(&nd);
path_put(&nd.path);
}
return retval;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/kernel/sysirix.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ asmlinkage int irix_statfs(const char __user *path,
}

dput_and_out:
path_release(&nd);
path_put(&nd.path);
out:
return error;
}
Expand Down Expand Up @@ -1385,7 +1385,7 @@ asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
error |= __put_user(0, &buf->f_fstr[i]);

dput_and_out:
path_release(&nd);
path_put(&nd.path);
out:
return error;
}
Expand Down Expand Up @@ -1636,7 +1636,7 @@ asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *
error |= __put_user(0, &buf->f_fstr[i]);

dput_and_out:
path_release(&nd);
path_put(&nd.path);
out:
return error;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/hpux/sys_hpux.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ asmlinkage long hpux_statfs(const char __user *path,
error = vfs_statfs_hpux(nd.path.dentry, &tmp);
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
error = -EFAULT;
path_release(&nd);
path_put(&nd.path);
}
return error;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
LOOKUP_OPEN|LOOKUP_CREATE, &nd);
if (!ret) {
ret = spufs_create(&nd, flags, mode, neighbor);
path_release(&nd);
path_put(&nd.path);
}
putname(tmp);
}
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc64/solaris/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ asmlinkage int solaris_statvfs(u32 path, u32 buf)
if (!error) {
struct inode *inode = nd.path.dentry->d_inode;
error = report_statvfs(nd.path.mnt, inode, buf);
path_release(&nd);
path_put(&nd.path);
}
return error;
}
Expand Down Expand Up @@ -466,7 +466,7 @@ asmlinkage int solaris_statvfs64(u32 path, u32 buf)
if (!error) {
struct inode *inode = nd.path.dentry->d_inode;
error = report_statvfs64(nd.path.mnt, inode, buf);
path_release(&nd);
path_put(&nd.path);
}
unlock_kernel();
return error;
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static int lookup_device(const char *path, dev_t *dev)
*dev = inode->i_rdev;

out:
path_release(&nd);
path_put(&nd.path);
return r;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/mtdsuper.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
goto not_an_MTD_device;

mtdnr = iminor(nd.path.dentry->d_inode);
path_release(&nd);
path_put(&nd.path);

return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
mnt);
Expand All @@ -214,7 +214,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
"MTD: Attempt to mount non-MTD device \"%s\"\n",
dev_name);
out:
path_release(&nd);
path_put(&nd.path);
return ret;

}
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/mntpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)

newmnt = afs_mntpt_do_automount(nd->path.dentry);
if (IS_ERR(newmnt)) {
path_release(nd);
path_put(&nd->path);
return (void *)newmnt;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;

out_error:
path_release(nd);
path_put(&nd->path);
return ERR_PTR(status);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ struct block_device *lookup_bdev(const char *path)
if (!bdev)
goto fail;
out:
path_release(&nd);
path_put(&nd.path);
return bdev;
fail:
bdev = ERR_PTR(error);
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifs_dfs_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
cFYI(1, ("leaving %s" , __FUNCTION__));
return ERR_PTR(rc);
out_err:
path_release(nd);
path_put(&nd->path);
goto out;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/coda/pioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp,

/* return if it is not a Coda inode */
if ( target_inode->i_sb != inode->i_sb ) {
path_release(&nd);
path_put(&nd.path);
return -EINVAL;
}

Expand All @@ -89,7 +89,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp,

error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);

path_release(&nd);
path_put(&nd.path);
return error;
}

4 changes: 2 additions & 2 deletions fs/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs
error = vfs_statfs(nd.path.dentry, &tmp);
if (!error)
error = put_compat_statfs(buf, &tmp);
path_release(&nd);
path_put(&nd.path);
}
return error;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, s
error = vfs_statfs(nd.path.dentry, &tmp);
if (!error)
error = put_compat_statfs64(buf, &tmp);
path_release(&nd);
path_put(&nd.path);
}
return error;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/configfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static int get_target(const char *symname, struct nameidata *nd,
*target = configfs_get_config_item(nd->path.dentry);
if (!*target) {
ret = -ENOENT;
path_release(nd);
path_put(&nd->path);
}
} else
ret = -EPERM;
Expand Down Expand Up @@ -141,7 +141,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
ret = create_link(parent_item, target_item, dentry);

config_item_put(target_item);
path_release(&nd);
path_put(&nd.path);

out_put:
config_item_put(parent_item);
Expand Down
2 changes: 1 addition & 1 deletion fs/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
error = vfs_quota_on_inode(nd.path.dentry->d_inode, type,
format_id);
out_path:
path_release(&nd);
path_put(&nd.path);
return error;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/ecryptfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
rc = 0;
goto out;
out_free:
path_release(&nd);
path_put(&nd.path);
out:
return rc;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ asmlinkage long sys_uselib(const char __user * library)
return error;
exit:
release_open_intent(&nd);
path_release(&nd);
path_put(&nd.path);
goto out;
}

Expand Down Expand Up @@ -672,7 +672,7 @@ struct file *open_exec(const char *name)
}
}
release_open_intent(&nd);
path_release(&nd);
path_put(&nd.path);
}
goto out;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2759,15 +2759,15 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
return err;
/* Quotafile not on the same filesystem? */
if (nd.path.mnt->mnt_sb != sb) {
path_release(&nd);
path_put(&nd.path);
return -EXDEV;
}
/* Quotafile not of fs root? */
if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
printk(KERN_WARNING
"EXT3-fs: Quota file not on filesystem root. "
"Journalled quota will not work.\n");
path_release(&nd);
path_put(&nd.path);
return vfs_quota_on(sb, type, format_id, path);
}

Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3159,15 +3159,15 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
return err;
/* Quotafile not on the same filesystem? */
if (nd.path.mnt->mnt_sb != sb) {
path_release(&nd);
path_put(&nd.path);
return -EXDEV;
}
/* Quotafile not of fs root? */
if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
printk(KERN_WARNING
"EXT4-fs: Quota file not on filesystem root. "
"Journalled quota will not work.\n");
path_release(&nd);
path_put(&nd.path);
return vfs_quota_on(sb, type, format_id, path);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/ops_fstype.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ static struct super_block* get_gfs2_sb(const char *dev_name)
"mount point %s\n", dev_name);

free_nd:
path_release(&nd);
path_put(&nd.path);
out:
return sb;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/inotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
/* you can only watch an inode if you have read permissions on it */
error = vfs_permission(nd, MAY_READ);
if (error)
path_release(nd);
path_put(&nd->path);
return error;
}

Expand Down Expand Up @@ -676,7 +676,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
ret = create_watch(dev, inode, mask);
mutex_unlock(&dev->up_mutex);

path_release(&nd);
path_put(&nd.path);
fput_and_out:
fput_light(filp, fput_needed);
return ret;
Expand Down
Loading

0 comments on commit 1d957f9

Please sign in to comment.