Skip to content

Commit 3c44080

Browse files
committed
device: add hasSymbol guard to GetAddressingModeAsString
While debugging nvidia-dra-driver-gpu on a test cluster running NVIDIA driver 570.148.08, the kubelet-plugin was crashing on startup because GetAddressingModeAsString() calls nvmlDeviceGetAddressingMode without checking whether the symbol exists in the loaded NVML library. That API was added in NVML v580 (driver 580+), so on older drivers the symbol is absent from libnvml.so. Since the library is opened with RTLD_LAZY, the first call crashes the process. IsCoherent() already guards against this with hasSymbol(). This applies the same pattern to GetAddressingModeAsString(). Callers now get ("", nil) when the symbol is missing, which is the same result they already get when the symbol is present but returns ERROR_NOT_SUPPORTED. Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>
1 parent d0c20b7 commit 3c44080

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

pkg/nvlib/device/device.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ func (d *device) GetBrandAsString() (string, error) {
149149

150150
// GetAddressingModeAsString returns the Device addressing mode as a string.
151151
func (d *device) GetAddressingModeAsString() (string, error) {
152-
mode, ret := d.GetAddressingMode()
152+
if !d.lib.hasSymbol("nvmlDeviceGetAddressingMode") {
153+
return "", nil
154+
}
155+
156+
mode, ret := nvml.Device(d).GetAddressingMode()
153157

154158
switch ret {
155159
case nvml.SUCCESS:

0 commit comments

Comments
 (0)