cgroup_pidlist_destroy_all(cgrp);
+ kernfs_put(cgrp->kn);
+
kfree(rcu_dereference_raw(cgrp->name));
kfree(cgrp);
}
}
cgrp->kn = kn;
+ /*
+ * This extra ref will be put in cgroup_free_fn() and guarantees
+ * that @cgrp->kn is always accessible.
+ */
+ kernfs_get(kn);
+
cgrp->serial_nr = cgroup_serial_nr_next++;
/* allocation complete, commit to creation */
{
struct cgroup *child;
struct cgroup_subsys_state *css;
- struct kernfs_node *kn;
bool empty;
int ssid;
* clearing of cgrp->kn->priv backpointer, which should happen
* after all files under it have been removed.
*/
- kn = cgrp->kn;
- kernfs_get(kn);
-
- kernfs_remove(cgrp->kn);
-
+ kernfs_remove(cgrp->kn); /* @cgrp has an extra ref on its kn */
RCU_INIT_POINTER(*(void __rcu __force **)&cgrp->kn->priv, NULL);
- kernfs_put(kn);
mutex_lock(&cgroup_mutex);