[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-34b65affe18daad31fed83e50d1f3b817786a2b7@git.kernel.org>
Date: Thu, 30 May 2019 01:14:46 -0700
From: tip-bot for Donald Yandt <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: yanmin_zhang@...ux.intel.com, jolsa@...hat.com, hpa@...or.com,
mingo@...nel.org, donald.yandt@...il.com,
linux-kernel@...r.kernel.org, tglx@...utronix.de,
alexander.shishkin@...ux.intel.com, peterz@...radead.org,
acme@...hat.com
Subject: [tip:perf/core] perf machine: Return NULL instead of
null-terminating /proc/version array
Commit-ID: 34b65affe18daad31fed83e50d1f3b817786a2b7
Gitweb: https://git.kernel.org/tip/34b65affe18daad31fed83e50d1f3b817786a2b7
Author: Donald Yandt <donald.yandt@...il.com>
AuthorDate: Tue, 28 May 2019 09:41:28 -0400
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 28 May 2019 18:37:44 -0300
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@...il.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Yanmin Zhang <yanmin_zhang@...ux.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@...hat.com>
---
tools/perf/util/machine.c | 4 ++--
1 file 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)
Powered by blists - more mailing lists