Skip to content

Commit 6a25e88

Browse files
committed
Fix bug for missing files in /proc/driver/nvidia
If one of the files (params, version, registry) in /proc/driver/nvidia is missing the path for the next file is concatenated on the previous one. This change ensures that the string storing the path is reset if one of the files is not found. Signed-off-by: Evan Lezar <[email protected]>
1 parent fc1b6c4 commit 6a25e88

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pkg/deb/changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
libnvidia-container (1.6.0~rc.2-1) experimental; urgency=medium
22

3-
-- NVIDIA CORPORATION <[email protected]> Tue, 26 Oct 2021 12:24:22 +0200
3+
* Fix bug that lead to unexected mount error when /proc/driver/nvidia does not exist on the host
44

5+
-- NVIDIA CORPORATION <[email protected]> Tue, 26 Oct 2021 12:24:22 +0200
56

67
libnvidia-container (1.6.0~rc.1-1) experimental; urgency=medium
78

pkg/rpm/SPECS/libnvidia-container.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ This package contains command-line tools that facilitate using the library.
100100

101101
%changelog
102102
* Tue Oct 26 2021 NVIDIA CORPORATION <[email protected]> 1.6.0-0.1.rc.2
103+
- Fix bug that lead to unexected mount error when /proc/driver/nvidia does not exist on the host
103104

104105
* Mon Sep 20 2021 NVIDIA CORPORATION <[email protected]> 1.6.0-0.1.rc.1
105106
- Add AARCH64 package for Amazon Linux 2

src/nvc_mount.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,14 @@ mount_procfs(struct error *err, const char *root, const struct nvc_container *cn
351351
if (path_append(err, dst, files[i]) < 0)
352352
goto fail;
353353
if (file_mode(err, src, &mode) < 0) {
354-
if (err->code == ENOENT)
354+
if (err->code == ENOENT) {
355+
log_warnf("%s not found; skipping", src);
356+
// We reset the strings to ensure that the paths are
357+
// not concatenated if one of the files is not found.
358+
*src_end = '\0';
359+
*dst_end = '\0';
355360
continue;
361+
}
356362
goto fail;
357363
}
358364
if (file_read_text(err, src, &buf) < 0)

0 commit comments

Comments
 (0)