[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20211222042546.6750-1-linmq006@gmail.com>
Date: Wed, 22 Dec 2021 04:25:46 +0000
From: Miaoqian Lin <linmq006@...il.com>
To: acme@...nel.org
Cc: ak@...ux.intel.com, alexander.shishkin@...ux.intel.com,
german.gomez@....com, irogers@...gle.com, jolsa@...hat.com,
linmq006@...il.com, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, mark.rutland@....com,
mingo@...hat.com, namhyung@...nel.org, peterz@...radead.org
Subject: [PATCH v4] perf expr: Fix return value of ids__new
callers of ids__new() function only do NULL checking for the return
value. ids__new() calles hashmap__new(), which may return
ERR_PTR(-ENOMEM). Instead of changing the checking one-by-one.
return NULL instead of ERR_PTR(-ENOMEM) to keep
consistent.
Signed-off-by: Miaoqian Lin <linmq006@...il.com>
Tested-by: German Gomez <german.gomez@....com>
Reviewed-by: German Gomez <german.gomez@....com>
---
Changes in v4:
fix the separator in commit message.
---
tools/perf/util/expr.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index 1d532b9fed29..f225247acc01 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -12,6 +12,7 @@
#include "expr-bison.h"
#include "expr-flex.h"
#include "smt.h"
+#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>
#include <ctype.h>
@@ -65,7 +66,12 @@ static bool key_equal(const void *key1, const void *key2,
struct hashmap *ids__new(void)
{
- return hashmap__new(key_hash, key_equal, NULL);
+ struct hashmap *hash;
+
+ hash = hashmap__new(key_hash, key_equal, NULL);
+ if (IS_ERR(hash))
+ return NULL;
+ return hash;
}
void ids__free(struct hashmap *ids)
--
2.17.1
Powered by blists - more mailing lists