[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Yld2+LwhYYe8XXmU@kernel.org>
Date: Wed, 13 Apr 2022 22:20:56 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: cgel.zte@...il.com
Cc: mingo@...hat.com, mark.rutland@....com, peterz@...radead.org,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, irogers@...gle.com, james.clark@....com,
lv.ruyi@....com.cn, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] perf stat: fix error check return value of hashmap__new()
Em Wed, Apr 13, 2022 at 09:33:02AM +0000, cgel.zte@...il.com escreveu:
> From: Lv Ruyi <lv.ruyi@....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@....com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@....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
Powered by blists - more mailing lists