mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Li kunyu <kunyu@nfschina.com>, shuah@kernel.org
Cc: trenn@suse.com, ray.huang@amd.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] power: cpupower: utils: Add malloc return value check
Date: Tue, 18 Oct 2022 14:33:02 -0600	[thread overview]
Message-ID: <e07df85d-9b98-75b8-d773-1124278aeb2e@linuxfoundation.org> (raw)
In-Reply-To: <20221014042911.298308-1-kunyu@nfschina.com>

On 10/13/22 22:29, Li kunyu wrote:
> Add the check and judgment statement of malloc return value.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>   tools/power/cpupower/utils/helpers/misc.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
> index 9547b29254a7..eafdbd6d760c 100644
> --- a/tools/power/cpupower/utils/helpers/misc.c
> +++ b/tools/power/cpupower/utils/helpers/misc.c
> @@ -139,6 +139,8 @@ void print_online_cpus(void)
>   
>   	str_len = online_cpus->size * 5;
>   	online_cpus_str = (void *)malloc(sizeof(char) * str_len);
> +	if (unlikely(!online_cpus_str))
> +		return;

You don't need unlikely here.

>   
>   	if (!bitmask_isallclear(online_cpus)) {
>   		bitmask_displaylist(online_cpus_str, str_len, online_cpus);
> @@ -157,6 +159,8 @@ void print_offline_cpus(void)
>   
>   	str_len = offline_cpus->size * 5;
>   	offline_cpus_str = (void *)malloc(sizeof(char) * str_len);
> +	if (unlikely(!offline_cpus_str))
> +		return;

You don't need unlikely here.

>   
>   	if (!bitmask_isallclear(offline_cpus)) {
>   		bitmask_displaylist(offline_cpus_str, str_len, offline_cpus);

thanks,
-- Shuah

      reply	other threads:[~2022-10-18 20:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  4:29 Li kunyu
2022-10-18 20:33 ` 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=e07df85d-9b98-75b8-d773-1124278aeb2e@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=kunyu@nfschina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ray.huang@amd.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®