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