diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 9f9105a5..12242bd1 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -189,9 +189,6 @@ func GetAllSubsystems() ([]string, error) { s := bufio.NewScanner(f) for s.Scan() { - if err := s.Err(); err != nil { - return nil, err - } text := s.Text() if text[0] != '#' { parts := strings.Fields(text) @@ -200,6 +197,9 @@ func GetAllSubsystems() ([]string, error) { } } } + if err := s.Err(); err != nil { + return nil, err + } return subsystems, nil } @@ -265,10 +265,6 @@ func parseCgroupFromReader(r io.Reader) (map[string]string, error) { cgroups := make(map[string]string) for s.Scan() { - if err := s.Err(); err != nil { - return nil, err - } - text := s.Text() // from cgroups(7): // /proc/[pid]/cgroup @@ -285,6 +281,10 @@ func parseCgroupFromReader(r io.Reader) (map[string]string, error) { cgroups[subs] = parts[2] } } + if err := s.Err(); err != nil { + return nil, err + } + return cgroups, nil } diff --git a/libcontainer/seccomp/seccomp_linux.go b/libcontainer/seccomp/seccomp_linux.go index ec0ac1c0..518d2c38 100644 --- a/libcontainer/seccomp/seccomp_linux.go +++ b/libcontainer/seccomp/seccomp_linux.go @@ -212,10 +212,6 @@ func parseStatusFile(path string) (map[string]string, error) { status := make(map[string]string) for s.Scan() { - if err := s.Err(); err != nil { - return nil, err - } - text := s.Text() parts := strings.Split(text, ":") @@ -225,5 +221,9 @@ func parseStatusFile(path string) (map[string]string, error) { status[parts[0]] = parts[1] } + if err := s.Err(); err != nil { + return nil, err + } + return status, nil }