Skip to content

Commit df7f996

Browse files
committed
configfs: Don't try to d_delete() negative dentries.
When configfs is faking mkdir() on its subsystem or default group objects, it starts by adding a negative dentry. It then tries to instantiate the group. If that should fail, it must clean up after itself. I was using d_delete() here, but configfs_attach_group() promises to return an empty dentry on error. d_delete() explodes with the entry dentry. Let's try d_drop() instead. The unhashing is what we want for our dentry. Signed-off-by: Joel Becker <jlbec@evilplan.org>
1 parent df016c6 commit df7f996

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/configfs/dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ static int create_default_group(struct config_group *parent_group,
689689
sd = child->d_fsdata;
690690
sd->s_type |= CONFIGFS_USET_DEFAULT;
691691
} else {
692-
d_delete(child);
692+
BUG_ON(child->d_inode);
693+
d_drop(child);
693694
dput(child);
694695
}
695696
}
@@ -1683,7 +1684,8 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
16831684
err = configfs_attach_group(sd->s_element, &group->cg_item,
16841685
dentry);
16851686
if (err) {
1686-
d_delete(dentry);
1687+
BUG_ON(dentry->d_inode);
1688+
d_drop(dentry);
16871689
dput(dentry);
16881690
} else {
16891691
spin_lock(&configfs_dirent_lock);

0 commit comments

Comments
 (0)