summaryrefslogtreecommitdiff
path: root/cmd/podman/common
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-02-18 15:43:46 -0600
committerbaude <bbaude@redhat.com>2021-02-19 07:56:14 -0600
commitd6b0b54121558027d087b9dcd157cb7df9d0a778 (patch)
treee2b742821f6f6fa824eb9227bb88c29572148f34 /cmd/podman/common
parentb2bb05d598452f7653e5b9311e3bd844b767cb26 (diff)
downloadpodman-d6b0b54121558027d087b9dcd157cb7df9d0a778.tar.gz
podman-d6b0b54121558027d087b9dcd157cb7df9d0a778.tar.bz2
podman-d6b0b54121558027d087b9dcd157cb7df9d0a778.zip
Fix segfault in run with memory-swap
when unlimited (-1) was being passed to memory-swap, podman threw a segfault. Fixes #9429 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/common')
-rw-r--r--cmd/podman/common/specgen.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 975c76fd9..eff8b43aa 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -148,17 +148,16 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.Linu
}
if m := c.MemorySwap; len(m) > 0 {
var ms int64
- if m == "-1" {
- ms = int64(-1)
- s.ResourceLimits.Memory.Swap = &ms
- } else {
+ // only set memory swap if it was set
+ // -1 indicates unlimited
+ if m != "-1" {
ms, err = units.RAMInBytes(m)
+ memory.Swap = &ms
if err != nil {
return nil, errors.Wrapf(err, "invalid value for memory")
}
+ hasLimits = true
}
- memory.Swap = &ms
- hasLimits = true
}
if m := c.KernelMemory; len(m) > 0 {
mk, err := units.RAMInBytes(m)