All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: cgel.zte@gmail.com
Cc: mingo@redhat.com, mark.rutland@arm.com, peterz@infradead.org,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, irogers@google.com, james.clark@arm.com,
	lv.ruyi@zte.com.cn, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] perf stat: fix error check return value of hashmap__new()
Date: Wed, 13 Apr 2022 22:20:56 -0300	[thread overview]
Message-ID: <Yld2+LwhYYe8XXmU@kernel.org> (raw)
In-Reply-To: <20220413093302.2538128-1-lv.ruyi@zte.com.cn>

Em Wed, Apr 13, 2022 at 09:33:02AM +0000, cgel.zte@gmail.com escreveu:
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
> 
> hashmap__new() returns ERR_PTR(-ENOMEM) when it fails, so we should use
> IS_ERR() to check it in error handling path.

Thanks, applied.

- Arnaldo

 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
>  tools/perf/util/stat.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index ee6f03481215..817a2de264b4 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <errno.h>
> +#include <linux/err.h>
>  #include <inttypes.h>
>  #include <math.h>
>  #include <string.h>
> @@ -311,7 +312,7 @@ static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals,
>  
>  	if (!mask) {
>  		mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
> -		if (!mask)
> +		if (IS_ERR(mask))
>  			return -ENOMEM;
>  
>  		counter->per_pkg_mask = mask;
> -- 
> 2.25.1

-- 

- Arnaldo

      reply	other threads:[~2022-04-14  1:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  9:33 [PATCH] perf stat: fix error check return value of hashmap__new() cgel.zte
2022-04-14  1:20 ` Arnaldo Carvalho de Melo [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=Yld2+LwhYYe8XXmU@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=cgel.zte@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=lv.ruyi@zte.com.cn \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=zealci@zte.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.