aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-18 11:51:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-18 11:51:59 -0700
commit9e17632c0a146891c90a4353a160cfcf71f34b8f (patch)
tree9ab52130a11cdc9cac5f4727b773badf1279555f /fs/dcache.c
parentMerge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs (diff)
parentcoredump: only charge written data against RLIMIT_CORE (diff)
downloadwireguard-linux-9e17632c0a146891c90a4353a160cfcf71f34b8f.tar.xz
wireguard-linux-9e17632c0a146891c90a4353a160cfcf71f34b8f.zip
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs cleanups from Al Viro: "Assorted cleanups and fixes all over the place" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: coredump: only charge written data against RLIMIT_CORE coredump: get rid of coredump_params->written ecryptfs_lookup(): try either only encrypted or plaintext name ecryptfs: avoid multiple aliases for directories bpf: reject invalid names right in ->lookup() __d_alloc(): treat NULL name as QSTR("/", 1) mtd: switch ubi_open_volume_path() to vfs_stat() mtd: switch open_mtd_by_chdev() to use of vfs_stat()
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index e49ba7d1b957..c622872c12c5 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1571,7 +1571,11 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
* be overwriting an internal NUL character
*/
dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
- if (name->len > DNAME_INLINE_LEN-1) {
+ if (unlikely(!name)) {
+ static const struct qstr anon = QSTR_INIT("/", 1);
+ name = &anon;
+ dname = dentry->d_iname;
+ } else if (name->len > DNAME_INLINE_LEN-1) {
size_t size = offsetof(struct external_name, name[1]);
struct external_name *p = kmalloc(size + name->len,
GFP_KERNEL_ACCOUNT);
@@ -1829,9 +1833,7 @@ struct dentry *d_make_root(struct inode *root_inode)
struct dentry *res = NULL;
if (root_inode) {
- static const struct qstr name = QSTR_INIT("/", 1);
-
- res = __d_alloc(root_inode->i_sb, &name);
+ res = __d_alloc(root_inode->i_sb, NULL);
if (res)
d_instantiate(res, root_inode);
else
@@ -1872,7 +1874,6 @@ EXPORT_SYMBOL(d_find_any_alias);
static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
{
- static const struct qstr anonstring = QSTR_INIT("/", 1);
struct dentry *tmp;
struct dentry *res;
unsigned add_flags;
@@ -1886,7 +1887,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
if (res)
goto out_iput;
- tmp = __d_alloc(inode->i_sb, &anonstring);
+ tmp = __d_alloc(inode->i_sb, NULL);
if (!tmp) {
res = ERR_PTR(-ENOMEM);
goto out_iput;