mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 23:27:06 +00:00
perf record: Fix failed memory allocation for get_cpuid_str
[ Upstream commit 81fccd6ca5
]
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 <tmricht@linux.vnet.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20180117131611.34319-1-tmricht@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1fe5e88c38
commit
77d17d0e89
1 changed files with 1 additions and 1 deletions
|
@ -70,7 +70,7 @@ get_cpuid_str(void)
|
|||
{
|
||||
char *buf = malloc(128);
|
||||
|
||||
if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
|
||||
if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue