mcst-linux-kernel/patches-2024.06.26/lxd-3.0.0/0035-devices-fail-if-Nvidia...

27 lines
865 B
Diff

From 298c3b7ad90c6307e0b6debc81446e08f8bdde3a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner@ubuntu.com>
Date: Wed, 11 Apr 2018 17:00:04 +0200
Subject: devices: fail if Nvidia device minor is missing
Closes #4441.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
lxd/devices.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lxd/devices.go b/lxd/devices.go
index b023f3db..8aa057dc 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -211,6 +211,9 @@ func deviceLoadGpu() ([]gpuDevice, []nvidiaGpuDevices, error) {
}
strBuf := strings.TrimSpace(string(buf))
idx := strings.Index(strBuf, "Device Minor:")
+ if idx == -1 {
+ return nil, nil, fmt.Errorf("No device minor index detected")
+ }
idx += len("Device Minor:")
strBuf = strBuf[idx:]
strBuf = strings.TrimSpace(strBuf)