aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 20f9cb32b703..54c4ff2b1cee 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1933,17 +1933,17 @@ int setup_intlist(struct intlist **list, const char *list_str,
1933static bool symbol__read_kptr_restrict(void) 1933static bool symbol__read_kptr_restrict(void)
1934{ 1934{
1935 bool value = false; 1935 bool value = false;
1936 FILE *fp = fopen("/proc/sys/kernel/kptr_restrict", "r");
1936 1937
1937 if (geteuid() != 0) { 1938 if (fp != NULL) {
1938 FILE *fp = fopen("/proc/sys/kernel/kptr_restrict", "r"); 1939 char line[8];
1939 if (fp != NULL) {
1940 char line[8];
1941 1940
1942 if (fgets(line, sizeof(line), fp) != NULL) 1941 if (fgets(line, sizeof(line), fp) != NULL)
1943 value = atoi(line) != 0; 1942 value = (geteuid() != 0) ?
1943 (atoi(line) != 0) :
1944 (atoi(line) == 2);
1944 1945
1945 fclose(fp); 1946 fclose(fp);
1946 }
1947 } 1947 }
1948 1948
1949 return value; 1949 return value;