summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-04-24 10:54:44 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-04-25 11:13:02 +0200
commitc5322608a5b78d55381fc87985304ec515cd723d (patch)
tree83914da3cd990888f68a9952251eeaaef51602f1
parentb6411f716c18e55192c442acbe8fe5595b0c14f4 (diff)
downloadsystemd-c5322608a5b78d55381fc87985304ec515cd723d.tar.gz
core: adjust unit_get_ancestor_memory_{low,min}() to work with units which don't have a CGroupContext
Coverity doesn't like the fact that unit_get_cgroup_context() returns NULL for unit types that don't have a CGroupContext. We don't expect to call those functions with such unit types, so this isn't an immediate problem, but we can make things more robust by handling this case. CID #1400683, #1400684.
-rw-r--r--src/core/cgroup.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 946fab24c2..32d5605899 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -403,15 +403,12 @@ int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode)
assert(u); \
\
c = unit_get_cgroup_context(u); \
- \
- if (c->entry##_set) \
+ if (c && c->entry##_set) \
return c->entry; \
\
- while (UNIT_ISSET(u->slice)) { \
- u = UNIT_DEREF(u->slice); \
+ while ((u = UNIT_DEREF(u->slice))) { \
c = unit_get_cgroup_context(u); \
- \
- if (c->default_##entry##_set) \
+ if (c && c->default_##entry##_set) \
return c->default_##entry; \
} \
\