diff options
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r-- | fs/kernfs/dir.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 25d71a53cf43..03b688d19f69 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -820,15 +820,22 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, const unsigned char *path, const void *ns) { - static char path_buf[PATH_MAX]; /* protected by kernfs_mutex */ - size_t len = strlcpy(path_buf, path, PATH_MAX); - char *p = path_buf; - char *name; + size_t len; + char *p, *name; lockdep_assert_held(&kernfs_mutex); - if (len >= PATH_MAX) + /* grab kernfs_rename_lock to piggy back on kernfs_pr_cont_buf */ + spin_lock_irq(&kernfs_rename_lock); + + len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf)); + + if (len >= sizeof(kernfs_pr_cont_buf)) { + spin_unlock_irq(&kernfs_rename_lock); return NULL; + } + + p = kernfs_pr_cont_buf; while ((name = strsep(&p, "/")) && parent) { if (*name == '\0') @@ -836,6 +843,8 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, parent = kernfs_find_ns(parent, name, ns); } + spin_unlock_irq(&kernfs_rename_lock); + return parent; } @@ -1640,9 +1649,9 @@ static loff_t kernfs_dir_fop_llseek(struct file *file, loff_t offset, struct inode *inode = file_inode(file); loff_t ret; - mutex_lock(&inode->i_mutex); + inode_lock(inode); ret = generic_file_llseek(file, offset, whence); - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); return ret; } |