From: Shuah Khan <skhan@linuxfoundation.org>
To: Zhongqiu Han <quic_zhonhan@quicinc.com>,
trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com,
jkacur@redhat.com, peng.fan@nxp.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] pm: cpupower: bench: Prevent NULL dereference on malloc failure
Date: Wed, 19 Feb 2025 13:51:35 -0700 [thread overview]
Message-ID: <9f137f62-e182-4f00-97c1-5dca6e25b316@linuxfoundation.org> (raw)
In-Reply-To: <20250219122715.3892223-1-quic_zhonhan@quicinc.com>
On 2/19/25 05:27, Zhongqiu Han wrote:
> If malloc returns NULL due to low memory, 'config' pointer can be NULL.
> Add a check to prevent NULL dereference.
>
> Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
> ---
> tools/power/cpupower/bench/parse.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
> index 080678d9d74e..bd67c758b33a 100644
> --- a/tools/power/cpupower/bench/parse.c
> +++ b/tools/power/cpupower/bench/parse.c
> @@ -121,6 +121,10 @@ FILE *prepare_output(const char *dirname)
> struct config *prepare_default_config()
> {
> struct config *config = malloc(sizeof(struct config));
> + if (!config) {
> + perror("malloc");
> + return NULL;
> + }
>
> dprintf("loading defaults\n");
>
Thanks. Applied for Linux 6.15-rc1 - will be included in pull request
to PM maintainer.
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/log/?h=cpupower
thanks,
-- Shuah
prev parent reply other threads:[~2025-02-19 20:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 12:27 Zhongqiu Han
2025-02-19 20:51 ` Shuah Khan [this message]
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=9f137f62-e182-4f00-97c1-5dca6e25b316@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=jkacur@redhat.com \
--cc=jwyatt@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=quic_zhonhan@quicinc.com \
--cc=shuah@kernel.org \
--cc=trenn@suse.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
all inboxes | Powered by JetHome®