From 9dcea81ea24519abc5a667ad9baaaa950c804eac Mon Sep 17 00:00:00 2001 From: "WANG, Miaoxiang" Date: Wed, 10 Jun 2026 15:48:50 +0800 Subject: [PATCH] Fix nil pointer panic in verifyDisabledVFs for non-SR-IOV GPUs GPUs that do not support SR-IOV (e.g. NVIDIA T400) have SriovInfo.PhysicalFunction set to nil. The existing code dereferences PhysicalFunction.NumVFs without a nil check, causing a panic when VFIO passthrough is configured for such GPUs. Add nil checks for both the gpu return value and PhysicalFunction. A nil PhysicalFunction means no VFs can exist, so it is safe to proceed. Signed-off-by: Miaoxiang --- cmd/gpu-kubelet-plugin/vfio-device.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/gpu-kubelet-plugin/vfio-device.go b/cmd/gpu-kubelet-plugin/vfio-device.go index 54c935daa..0b3697e96 100644 --- a/cmd/gpu-kubelet-plugin/vfio-device.go +++ b/cmd/gpu-kubelet-plugin/vfio-device.go @@ -134,6 +134,14 @@ func (vm *VfioPciManager) verifyDisabledVFs(pciBusID string) error { if err != nil { return err } + if gpu == nil { + return fmt.Errorf("no GPU found at PCI bus ID %q", pciBusID) + } + // PhysicalFunction is nil for GPUs that do not support SR-IOV (e.g. T400). + // A nil PhysicalFunction means no VFs can exist, so it is safe to proceed. + if gpu.SriovInfo.PhysicalFunction == nil { + return nil + } numVFs := gpu.SriovInfo.PhysicalFunction.NumVFs if numVFs > 0 { return fmt.Errorf("gpu has %d VFs, cannot unbind", numVFs)