Skip to content

Commit d73f5d1

Browse files
Lv Ruyiacmel
authored andcommitted
perf stat: Fix error check return value of hashmap__new(), must use IS_ERR()
hashmap__new() returns ERR_PTR(-ENOMEM) when it fails, so we should use IS_ERR() to check it in error handling path. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20220413093302.2538128-1-lv.ruyi@zte.com.cn Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f034fc5 commit d73f5d1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools/perf/util/stat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <errno.h>
3+
#include <linux/err.h>
34
#include <inttypes.h>
45
#include <math.h>
56
#include <string.h>
@@ -311,7 +312,7 @@ static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals,
311312

312313
if (!mask) {
313314
mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
314-
if (!mask)
315+
if (IS_ERR(mask))
315316
return -ENOMEM;
316317

317318
counter->per_pkg_mask = mask;

0 commit comments

Comments
 (0)