Skip to content

Commit 798434b

Browse files
author
Al Viro
committed
__d_alloc(): treat NULL name as QSTR("/", 1)
Signed-off-by: Al Viro <[email protected]>
1 parent 322ea0b commit 798434b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/dcache.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,11 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
15581558
* be overwriting an internal NUL character
15591559
*/
15601560
dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
1561-
if (name->len > DNAME_INLINE_LEN-1) {
1561+
if (unlikely(!name)) {
1562+
static const struct qstr anon = QSTR_INIT("/", 1);
1563+
name = &anon;
1564+
dname = dentry->d_iname;
1565+
} else if (name->len > DNAME_INLINE_LEN-1) {
15621566
size_t size = offsetof(struct external_name, name[1]);
15631567
struct external_name *p = kmalloc(size + name->len,
15641568
GFP_KERNEL_ACCOUNT);
@@ -1812,9 +1816,7 @@ struct dentry *d_make_root(struct inode *root_inode)
18121816
struct dentry *res = NULL;
18131817

18141818
if (root_inode) {
1815-
static const struct qstr name = QSTR_INIT("/", 1);
1816-
1817-
res = __d_alloc(root_inode->i_sb, &name);
1819+
res = __d_alloc(root_inode->i_sb, NULL);
18181820
if (res)
18191821
d_instantiate(res, root_inode);
18201822
else
@@ -1855,7 +1857,6 @@ EXPORT_SYMBOL(d_find_any_alias);
18551857

18561858
static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
18571859
{
1858-
static const struct qstr anonstring = QSTR_INIT("/", 1);
18591860
struct dentry *tmp;
18601861
struct dentry *res;
18611862
unsigned add_flags;
@@ -1869,7 +1870,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
18691870
if (res)
18701871
goto out_iput;
18711872

1872-
tmp = __d_alloc(inode->i_sb, &anonstring);
1873+
tmp = __d_alloc(inode->i_sb, NULL);
18731874
if (!tmp) {
18741875
res = ERR_PTR(-ENOMEM);
18751876
goto out_iput;

0 commit comments

Comments
 (0)