diff --git a/libcontainer/cgroups/systemd/unified_hierarchy.go b/libcontainer/cgroups/systemd/unified_hierarchy.go index 2dffc34e0..36ccf2716 100644 --- a/libcontainer/cgroups/systemd/unified_hierarchy.go +++ b/libcontainer/cgroups/systemd/unified_hierarchy.go @@ -241,6 +241,7 @@ func createCgroupsv2Path(path string) (Err error) { } } else { // If the directory was created, be sure it is not left around on errors. + current := current defer func() { if Err != nil { os.Remove(current)