summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-09 04:11:23 +0400
committerTejun Heo <tj@kernel.org>2013-08-09 04:11:23 +0400
commita7c6d554aa01236ac2a9f851ab0f75704f76dfa2 (patch)
treefe62d07283a589daa39f843deaefafd11c572b84 /security
parent72c97e54e0f043d33b246d7460ae0a36c4b8c643 (diff)
downloadlinux-a7c6d554aa01236ac2a9f851ab0f75704f76dfa2.tar.xz
cgroup: add/update accessors which obtain subsys specific data from css
css (cgroup_subsys_state) is usually embedded in a subsys specific data structure. Subsystems either use container_of() directly to cast from css to such data structure or has an accessor function wrapping such cast. As cgroup as whole is moving towards using css as the main interface handle, add and update such accessors to ease dealing with css's. All accessors explicitly handle NULL input and return NULL in those cases. While this looks like an extra branch in the code, as all controllers specific data structures have css as the first field, the casting doesn't involve any offsetting and the compiler can trivially optimize out the branch. * blkio, freezer, cpuset, cpu, cpuacct and net_cls didn't have such accessor. Added. * memory, hugetlb and devices already had one but didn't explicitly handle NULL input. Updated. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'security')
-rw-r--r--security/device_cgroup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 87a0a037fbd6..90953648c643 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -53,7 +53,7 @@ struct dev_cgroup {
static inline struct dev_cgroup *css_to_devcgroup(struct cgroup_subsys_state *s)
{
- return container_of(s, struct dev_cgroup, css);
+ return s ? container_of(s, struct dev_cgroup, css) : NULL;
}
static inline struct dev_cgroup *cgroup_to_devcgroup(struct cgroup *cgroup)