kernel: cgroup: protecting css_set object
Accessing the css_set object should be protected with css_set_lock.
NULL check is required before accesing object.
CRs-fixed: 723762
Change-Id: Ia3a0314a04419889d5002a8f2bf2c1fe9dfa3671
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2f0d7542..511d6b5 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3960,12 +3960,16 @@
{
struct cg_cgroup_link *link;
+ read_lock(&css_set_lock);
list_for_each_entry(link, &cgrp->css_sets, cgrp_link_list) {
struct css_set *cg = link->cg;
- if (atomic_read(&cg->refcount) > 0)
+ if (cg && (atomic_read(&cg->refcount) > 0)) {
+ read_unlock(&css_set_lock);
return 0;
+ }
}
+ read_unlock(&css_set_lock);
return 1;
}