summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate/config_linux.go
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2020-05-27 14:51:31 -0400
committerPeter Hunt <pehunt@redhat.com>2020-05-27 14:52:17 -0400
commit339ffd8ade8098a7f872fce9e10ca91f1802677d (patch)
tree0a8dceec4976443d6883410494b4eb807afdbc44 /pkg/specgen/generate/config_linux.go
parentab3a620f74f2f1458054822f2113200863b60d40 (diff)
downloadpodman-339ffd8ade8098a7f872fce9e10ca91f1802677d.tar.gz
podman-339ffd8ade8098a7f872fce9e10ca91f1802677d.tar.bz2
podman-339ffd8ade8098a7f872fce9e10ca91f1802677d.zip
specgen: fix segfault
we should not access the devices without checking if the resources are there Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'pkg/specgen/generate/config_linux.go')
-rw-r--r--pkg/specgen/generate/config_linux.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/specgen/generate/config_linux.go b/pkg/specgen/generate/config_linux.go
index 1b2a2ac32..f4cf0c704 100644
--- a/pkg/specgen/generate/config_linux.go
+++ b/pkg/specgen/generate/config_linux.go
@@ -72,13 +72,17 @@ func addPrivilegedDevices(g *generate.Generator) error {
newMounts = append(newMounts, devMnt)
}
g.Config.Mounts = append(newMounts, g.Config.Mounts...)
- g.Config.Linux.Resources.Devices = nil
+ if g.Config.Linux.Resources != nil {
+ g.Config.Linux.Resources.Devices = nil
+ }
} else {
for _, d := range hostDevices {
g.AddDevice(Device(d))
}
// Add resources device - need to clear the existing one first.
- g.Config.Linux.Resources.Devices = nil
+ if g.Config.Linux.Resources != nil {
+ g.Config.Linux.Resources.Devices = nil
+ }
g.AddLinuxResourcesDevice(true, "", nil, nil, "rwm")
}