Skip to content

Commit

Permalink
cgroups/fs: check nil pointers in cgroup manager
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Sipsma <sipsma@amazon.com>
  • Loading branch information
sipsma committed Aug 14, 2019
1 parent 2e94378 commit 9c822e4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libcontainer/cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,13 @@ func (m *Manager) GetStats() (*cgroups.Stats, error) {
}

func (m *Manager) Set(container *configs.Config) error {
if container.Cgroups == nil {
return nil
}

// If Paths are set, then we are just joining cgroups paths
// and there is no need to set any values.
if m.Cgroups.Paths != nil {
if m.Cgroups != nil && m.Cgroups.Paths != nil {
return nil
}

Expand Down Expand Up @@ -262,6 +266,10 @@ func (m *Manager) Set(container *configs.Config) error {
// Freeze toggles the container's freezer cgroup depending on the state
// provided
func (m *Manager) Freeze(state configs.FreezerState) error {
if m.Cgroups == nil {
return errors.New("cannot toggle freezer: cgroups not configured for container")
}

paths := m.GetPaths()
dir := paths["freezer"]
prevState := m.Cgroups.Resources.Freezer
Expand Down

0 comments on commit 9c822e4

Please sign in to comment.