summaryrefslogtreecommitdiffstats
path: root/system/nvidia-legacy390-driver/nvidia-installer-removed-sysctl-h.patch
blob: df61dfa85d1b5229ef6fbba8fd6daf45df931de1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
diff -Nur nvidia-installer-390.143.orig/kernel.c nvidia-installer-390.143/kernel.c
--- nvidia-installer-390.143.orig/kernel.c	2021-03-12 02:29:56.000000000 -0500
+++ nvidia-installer-390.143/kernel.c	2021-06-23 11:15:12.813980616 -0400
@@ -23,7 +23,6 @@
 #include <sys/utsname.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/sysctl.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <dirent.h>
@@ -1055,9 +1050,9 @@
 #define PRINTK_LOGLEVEL_KERN_ALERT 1
 
 /*
- * Attempt to set the printk loglevel, first using the /proc/sys interface,
- * and falling back to the deprecated sysctl if that fails. Pass the previous
- * loglevel back to the caller and return TRUE on success, or FALSE on failure.
+ * Attempt to set the printk loglevel using the /proc/sys interface.
+ * Pass the previous loglevel back to the caller and return TRUE on success,
+ * or FALSE on failure.
  */
 static int set_loglevel(int level, int *old_level)
 {
@@ -1067,6 +1062,9 @@
     fp = fopen("/proc/sys/kernel/printk", "r+");
     if (fp) {
         if (!old_level || fscanf(fp, "%d ", old_level) == 1) {
+            /* Use a dynamic buffer for the string: the kernel does not range
+             * check the loglevel, so the value reported by the procfs file
+             * may have an unknown number of digits. */
             char *strlevel = nvasprintf("%d", level);
 
             fseek(fp, 0, SEEK_SET);
@@ -1079,23 +1077,6 @@
         fclose(fp);
     }
 
-    if (!loglevel_set) {
-        /*
-         * Explicitly initialize the value of len, even though it looks like the
-         * syscall should do that, since in practice it doesn't always actually
-         * set the value of the pointed-to length parameter.
-         */
-        size_t len = sizeof(int);
-        int name[] = { CTL_KERN, KERN_PRINTK };
-
-        if (!old_level ||
-            sysctl(name, ARRAY_LEN(name), old_level, &len, NULL, 0) == 0) {
-            if (sysctl(name, ARRAY_LEN(name), NULL, 0, &level, len) == 0) {
-                loglevel_set = TRUE;
-            }
-        }
-    }
-
     return loglevel_set;
 }