From 339ffd8ade8098a7f872fce9e10ca91f1802677d Mon Sep 17 00:00:00 2001 From: Peter Hunt Date: Wed, 27 May 2020 14:51:31 -0400 Subject: specgen: fix segfault we should not access the devices without checking if the resources are there Signed-off-by: Peter Hunt --- pkg/specgen/generate/config_linux.go | 8 ++++++-- 1 file 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") } -- cgit v1.2.3-54-g00ecf