Skip to content

fix: nvidia-installer failure aborts under set -e before $? check - #948

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-nvidia-installer-failure-aborts-under
Open

fix: nvidia-installer failure aborts under set -e before $? check#948
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-nvidia-installer-failure-aborts-under

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in ubuntu24.04/nvidia-driver: nvidia-installer failure aborts under set -e before $? check.

Changes

  • ubuntu24.04/nvidia-driver: nvidia-installer failure aborts under set -e before $? check.

Details

--- a/ubuntu24.04/nvidia-driver
+++ b/ubuntu24.04/nvidia-driver
@@ -1,6 +1,5 @@
-    kernel_module_type=$(nvidia-installer --print-recommended-kernel-module-type)
-    if [ $? -ne 0 ]; then
-      echo "failed to retrieve the recommended kernel module type from nvidia-installer, falling back to using the driver branch"
-      _resolve_kernel_type_from_driver_branch
-      return 0
-    fi
+    if ! kernel_module_type=$(nvidia-installer --print-recommended-kernel-module-type); then
+      echo "failed to retrieve the recommended kernel module type from nvidia-installer, falling back to using the driver branch"
+      _resolve_kernel_type_from_driver_branch
+      return 0
+    fi

Tests

  • tests/test_resolve_kernel_type.sh
--- /dev/null
+++ tests/test_resolve_kernel_type.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -eu
+
+DRIVER_FILE="ubuntu24.04/nvidia-driver"
+
+if grep -F '    kernel_module_type=$(nvidia-installer --print-recommended-kernel-module-type)' "$DRIVER_FILE"; then
+    echo "FAIL: nvidia-installer uses unchecked command substitution" >&2
+    exit 1
+fi
+
+echo "PASS: nvidia-installer error is caught with conditional command substitution"

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant