linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg
@ 2021-12-12  4:23 Miaoqian Lin
  2021-12-12 14:55 ` German Gomez
  0 siblings, 1 reply; 7+ messages in thread
From: Miaoqian Lin @ 2021-12-12  4:23 UTC (permalink / raw)
  Cc: linmq006, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	James Clark, Kan Liang, Song Liu, Jin Yao, linux-perf-users,
	linux-kernel

The hashmap__new() function does not return NULL on errors. It returns
ERR_PTR(-ENOMEM). Using IS_ERR() to check the return value
to fix this.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 tools/perf/util/stat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 09ea334586f2..a77052680087 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -311,8 +311,8 @@ static int check_per_pkg(struct evsel *counter,
 
 	if (!mask) {
 		mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
-		if (!mask)
-			return -ENOMEM;
+		if (IS_ERR(mask))
+			return PTR_ERR(mask);
 
 		counter->per_pkg_mask = mask;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-13 16:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-12  4:23 [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg Miaoqian Lin
2021-12-12 14:55 ` German Gomez
2021-12-12 15:37   ` German Gomez
2021-12-13  7:09   ` [PATCH] perf expr: Fix return value of ids__new Miaoqian Lin
2021-12-13 13:13     ` German Gomez
2021-12-13 16:02       ` German Gomez
2021-12-13 13:57     ` German Gomez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).