libct/cgroups: fix m.paths map access

This fixes a few cases of accessing m.paths map directly without holding
the mutex lock.

Fixes: 9087f2e82
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-06-15 18:28:50 -07:00
parent a77d7b1d0f
commit dd2426d067
2 changed files with 4 additions and 2 deletions

View File

@ -393,5 +393,5 @@ func (m *manager) GetFreezerState() (configs.FreezerState, error) {
}
func (m *manager) Exists() bool {
return cgroups.PathExists(m.paths["devices"])
return cgroups.PathExists(m.Path("devices"))
}

View File

@ -112,6 +112,8 @@ func (m *legacyManager) Apply(pid int) error {
properties []systemdDbus.Property
)
m.mu.Lock()
defer m.mu.Unlock()
if c.Paths != nil {
paths := make(map[string]string)
for name, path := range c.Paths {
@ -465,5 +467,5 @@ func (m *legacyManager) GetFreezerState() (configs.FreezerState, error) {
}
func (m *legacyManager) Exists() bool {
return cgroups.PathExists(m.paths["devices"])
return cgroups.PathExists(m.Path("devices"))
}