From 89ccdfe98a4dc81046a59a44fff970501d70b347 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Thu, 22 Feb 2024 17:19:10 -0800 Subject: [PATCH] Fix nil pointer dereference in nvproxy specutils PiperOrigin-RevId: 609551204 --- runsc/specutils/nvidia.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runsc/specutils/nvidia.go b/runsc/specutils/nvidia.go index 7372a945d..36cedcc9e 100644 --- a/runsc/specutils/nvidia.go +++ b/runsc/specutils/nvidia.go @@ -98,9 +98,12 @@ func isNvidiaHookPresent(spec *specs.Spec, conf *config.Config) bool { // This has the effect of injecting the nvidia-container-runtime-hook. return true } - for _, h := range spec.Hooks.Prestart { - if strings.HasSuffix(h.Path, "/nvidia-container-runtime-hook") { - return true + + if spec.Hooks != nil { + for _, h := range spec.Hooks.Prestart { + if strings.HasSuffix(h.Path, "/nvidia-container-runtime-hook") { + return true + } } } return false