Skip to content

Commit 7b0f8d7

Browse files
Thomas Richtergregkh
authored andcommitted
perf record: Fix failed memory allocation for get_cpuid_str
[ Upstream commit 81fccd6 ] In x86 architecture dependend part function get_cpuid_str() mallocs a 128 byte buffer, but does not check if the memory allocation succeeded or not. When the memory allocation fails, function __get_cpuid() is called with first parameter being a NULL pointer. However this function references its first parameter and operates on a NULL pointer which might cause core dumps. Signed-off-by: Thomas Richter <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Hendrik Brueckner <[email protected]> Cc: Martin Schwidefsky <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d23d7b0 commit 7b0f8d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/arch/x86/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ get_cpuid_str(void)
6969
{
7070
char *buf = malloc(128);
7171

72-
if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
72+
if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
7373
free(buf);
7474
return NULL;
7575
}

0 commit comments

Comments
 (0)