summaryrefslogtreecommitdiffstats
path: root/fs/kernfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r--fs/kernfs/file.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index bdd38854ef65..231a171f48b6 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -856,9 +856,13 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
if (ops->mmap)
kn->flags |= KERNFS_HAS_MMAP;
- kernfs_addrm_start(&acxt);
- rc = kernfs_add_one(&acxt, kn, parent);
- kernfs_addrm_finish(&acxt);
+ rc = -ENOENT;
+ if (kernfs_get_active(parent)) {
+ kernfs_addrm_start(&acxt);
+ rc = kernfs_add_one(&acxt, kn, parent);
+ kernfs_addrm_finish(&acxt);
+ kernfs_put_active(parent);
+ }
if (rc) {
kernfs_put(kn);