* [PATCH] perf stat: fix error check return value of hashmap__new()
@ 2022-04-13 9:33 cgel.zte
2022-04-14 1:20 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-04-13 9:33 UTC (permalink / raw)
To: mingo, acme, mark.rutland
Cc: peterz, alexander.shishkin, jolsa, namhyung, irogers,
james.clark, lv.ruyi, linux-perf-users, linux-kernel, Zeal Robot
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.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf stat: fix error check return value of hashmap__new()
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
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-04-14 1:20 UTC (permalink / raw)
To: cgel.zte
Cc: mingo, mark.rutland, peterz, alexander.shishkin, jolsa, namhyung,
irogers, james.clark, lv.ruyi, linux-perf-users, linux-kernel,
Zeal Robot
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-14 1:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.