*/
static struct rdtgroup *kernfs_to_rdtgroup(struct kernfs_node *kn)
{
- if (kernfs_type(kn) == KERNFS_DIR)
- return kn->priv;
- else
+ if (kernfs_type(kn) == KERNFS_DIR) {
+ /*
+ * All the resource directories use "kn->priv"
+ * to point to the "struct rdtgroup" for the
+ * resource. "info" and its subdirectories don't
+ * have rdtgroup structures, so return NULL here.
+ */
+ if (kn == kn_info || kn->parent == kn_info)
+ return NULL;
+ else
+ return kn->priv;
+ } else {
return kn->parent->priv;
+ }
}
struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn)
{
struct rdtgroup *rdtgrp = kernfs_to_rdtgroup(kn);
+ if (!rdtgrp)
+ return NULL;
+
atomic_inc(&rdtgrp->waitcount);
kernfs_break_active_protection(kn);
{
struct rdtgroup *rdtgrp = kernfs_to_rdtgroup(kn);
+ if (!rdtgrp)
+ return;
+
mutex_unlock(&rdtgroup_mutex);
if (atomic_dec_and_test(&rdtgrp->waitcount) &&
rdtgrp = rdtgroup_kn_lock_live(kn);
if (!rdtgrp) {
rdtgroup_kn_unlock(kn);
- return -ENOENT;
+ return -EPERM;
}
/* Give any tasks back to the default group */