cgroup: fix RCU related sparse warnings
authorTejun Heo <tj@kernel.org>
Tue, 27 Dec 2016 19:49:09 +0000 (14:49 -0500)
committerTejun Heo <tj@kernel.org>
Tue, 27 Dec 2016 19:49:09 +0000 (14:49 -0500)
kn->priv which is a void * is used as a RCU pointer by cgroup.  When
dereferencing it, it was passing kn->priv to rcu_derefreence() without
casting it into a RCU pointer triggering address space mismatch
warning from sparse.  Fix them.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Acked-by: Zefan Li <lizefan@huawei.com>
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c

index 37be09e0974066fedcea4c6efb59cf1681f959e3..465b10111eaf3df63c51cdae1fec0d56be5d69a3 100644 (file)
@@ -694,7 +694,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
         * @kn->priv is RCU safe.  Let's do the RCU dancing.
         */
        rcu_read_lock();
-       cgrp = rcu_dereference(kn->priv);
+       cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
        if (!cgrp || cgroup_is_dead(cgrp)) {
                rcu_read_unlock();
                mutex_unlock(&cgroup_mutex);
index b6b9068ef468fab39a19e7b32592fb1b4bf5cab0..d9d82e96d67f05f8dbe037b4b0b9a05e77ed8743 100644 (file)
@@ -4932,7 +4932,7 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
         * have been or be removed at any point.  @kn->priv is RCU
         * protected for this access.  See css_release_work_fn() for details.
         */
-       cgrp = rcu_dereference(kn->priv);
+       cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
        if (cgrp)
                css = cgroup_css(cgrp, ss);