Messages in this thread Patch in this message | | | From | Miaoqian Lin <> | Subject | [PATCH] perf expr: Fix missing check for return value of hashmap__new | Date | Sun, 12 Dec 2021 06:25:02 +0000 |
| |
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
| |