summaryrefslogtreecommitdiff
path: root/libpod/runtime_ctr.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-07-01 09:23:21 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-07-02 12:51:39 -0400
commite92de11a69e5aa503fc2fe4ffd569133179cefa5 (patch)
treec5e86306017944634fc7a05ee846859a22824497 /libpod/runtime_ctr.go
parent4d45d8020e58841862791796ea4c0797a62540e9 (diff)
downloadpodman-e92de11a69e5aa503fc2fe4ffd569133179cefa5.tar.gz
podman-e92de11a69e5aa503fc2fe4ffd569133179cefa5.tar.bz2
podman-e92de11a69e5aa503fc2fe4ffd569133179cefa5.zip
Ensure locks are freed when ctr/pod creation fails
If we don't do this, we can leak locks on every failure, and that is very, very bad - can render Podman unusable without a 'system renumber' being run. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r--libpod/runtime_ctr.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 0d0f700a6..9daac161c 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -132,6 +132,14 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container, restore bo
ctr.config.LockID = ctr.lock.ID()
logrus.Debugf("Allocated lock %d for container %s", ctr.lock.ID(), ctr.ID())
+ defer func() {
+ if err != nil {
+ if err2 := ctr.lock.Free(); err2 != nil {
+ logrus.Errorf("Error freeing lock for container after creation failed: %v", err2)
+ }
+ }
+ }()
+
ctr.valid = true
ctr.state.State = config2.ContainerStateConfigured
ctr.runtime = r