]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
populate_group(): move cleanup on failure to the sole caller
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 12 May 2026 06:10:35 +0000 (02:10 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 8 Jun 2026 18:53:09 +0000 (14:53 -0400)
... where it folds with configfs_detach_item() into a call of
configfs_detach_group().

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/configfs/dir.c

index c420191610c36a9913067c922c8c27e2a2773503..01de8ef5fbe66ec606a47d74d97e3ac296ed8c22 100644 (file)
@@ -754,17 +754,13 @@ static int populate_groups(struct config_group *group,
                           struct configfs_fragment *frag)
 {
        struct config_group *new_group;
-       int ret = 0;
 
        list_for_each_entry(new_group, &group->default_groups, group_entry) {
-               ret = create_default_group(group, new_group, frag);
-               if (ret) {
-                       detach_groups(group);
-                       break;
-               }
+               int ret = create_default_group(group, new_group, frag);
+               if (ret)
+                       return ret;
        }
-
-       return ret;
+       return 0;
 }
 
 void configfs_remove_default_groups(struct config_group *group)
@@ -904,6 +900,13 @@ static void configfs_detach_item(struct config_item *item)
        configfs_remove_dir(item);
 }
 
+/* Caller holds the mutex of the group's inode */
+static void configfs_detach_group(struct config_item *item)
+{
+       detach_groups(to_config_group(item));
+       configfs_detach_item(item);
+}
+
 static int configfs_attach_group(struct config_item *parent_item,
                                 struct config_item *item,
                                 struct dentry *dentry,
@@ -930,7 +933,7 @@ static int configfs_attach_group(struct config_item *parent_item,
                configfs_adjust_dir_dirent_depth_before_populate(sd);
                ret = populate_groups(to_config_group(item), frag);
                if (ret) {
-                       configfs_detach_item(item);
+                       configfs_detach_group(item);
                        d_inode(dentry)->i_flags |= S_DEAD;
                        dont_mount(dentry);
                }
@@ -943,13 +946,6 @@ static int configfs_attach_group(struct config_item *parent_item,
        return ret;
 }
 
-/* Caller holds the mutex of the group's inode */
-static void configfs_detach_group(struct config_item *item)
-{
-       detach_groups(to_config_group(item));
-       configfs_detach_item(item);
-}
-
 /*
  * After the item has been detached from the filesystem view, we are
  * ready to tear it out of the hierarchy.  Notify the client before