From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com,
heiko.carstens@de.ibm.com
Subject: Re: [PATCH] perf record: Fix failed memory allocation for get_cpuid_str
Date: Wed, 17 Jan 2018 10:31:56 -0300 [thread overview]
Message-ID: <20180117133156.GG30880@kernel.org> (raw)
In-Reply-To: <20180117131611.34319-1-tmricht@linux.vnet.ibm.com>
Em Wed, Jan 17, 2018 at 02:16:11PM +0100, Thomas Richter escreveu:
> 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.
Thanks, applied.
- Arnaldo
> Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
> ---
> tools/perf/arch/x86/util/header.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c
> index 33027c5e6f92..c6b5204e0280 100644
> --- a/tools/perf/arch/x86/util/header.c
> +++ b/tools/perf/arch/x86/util/header.c
> @@ -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;
> }
> --
> 2.13.4
next prev parent reply other threads:[~2018-01-17 13:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 13:16 [PATCH] perf record: Fix failed memory allocation for get_cpuid_str Thomas Richter
2018-01-17 13:31 ` Arnaldo Carvalho de Melo [this message]
2018-01-17 16:38 ` [tip:perf/core] " tip-bot for Thomas Richter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180117133156.GG30880@kernel.org \
--to=acme@kernel.org \
--cc=brueckner@linux.vnet.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=tmricht@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox