All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf expr: Fix missing check for return value of hashmap__new
@ 2021-12-12  6:25 Miaoqian Lin
  2021-12-13 13:06 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Miaoqian Lin @ 2021-12-12  6:25 UTC (permalink / raw)
  Cc: linmq006, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Andi Kleen, linux-perf-users, linux-kernel

The hashmap__new() function may return ERR_PTR(-ENOMEM) when malloc
fails, add IS_ERR checking for ctx->ids.

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

diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 1d532b9fed29..c94c9ea30d1a 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -299,6 +299,10 @@ struct expr_parse_ctx *expr__ctx_new(void)
 		return NULL;
 
 	ctx->ids = hashmap__new(key_hash, key_equal, NULL);
+	if (IS_ERR(ctx->ids)) {
+		kfree(ctx);
+		return NULL;
+	}
 	ctx->runtime = 0;
 
 	return ctx;
-- 
2.17.1


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-12  6:25 [PATCH] perf expr: Fix missing check for return value of hashmap__new Miaoqian Lin
2021-12-13 13:06 ` Arnaldo Carvalho de Melo
2021-12-13 13:08   ` 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.