mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 15:43:59 +08:00
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: 30ba5b0e66
("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>
This commit is contained in:
parent
80ec26d110
commit
34b65affe1
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user