diff options
author | Donald Yandt <donald.yandt@gmail.com> | 2019-05-28 15:41:28 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-05-28 23:37:44 +0200 |
commit | 34b65affe18daad31fed83e50d1f3b817786a2b7 (patch) | |
tree | 1f94a5a9dd451cae8f7800c0433f69f4c205ab72 /tools/perf/util/machine.c | |
parent | perf version: Append 12 git SHA chars to the version string (diff) | |
download | linux-34b65affe18daad31fed83e50d1f3b817786a2b7.tar.xz linux-34b65affe18daad31fed83e50d1f3b817786a2b7.zip |
perf machine: Return NULL instead of null-terminating /proc/version array
Return NULL instead of null-terminating version char array when fgets
fails due to end-of-file or error.
Signed-off-by: Donald Yandt <donald.yandt@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Fixes: 30ba5b0e66c8 ("perf machine: Null-terminate version char array upon fgets(/proc/version) error")
Link: http://lkml.kernel.org/r/20190528134128.30841-1-donald.yandt@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r-- | tools/perf/util/machine.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f5569f005cf3..17eec39e775e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1241,9 +1241,9 @@ static char *get_kernel_version(const char *root_dir) return NULL; tmp = fgets(version, sizeof(version), file); - if (!tmp) - *version = '\0'; fclose(file); + if (!tmp) + return NULL; name = strstr(version, prefix); if (!name) |