From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>, Andi Kleen <ak@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf expr: Fix missing check for return value of hashmap__new
Date: Mon, 13 Dec 2021 10:08:48 -0300 [thread overview]
Message-ID: <YbdF4FtPY77Y6faW@kernel.org> (raw)
In-Reply-To: <YbdFOvHedDCVZ04A@kernel.org>
Em Mon, Dec 13, 2021 at 10:06:02AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Dec 12, 2021 at 06:25:02AM +0000, Miaoqian Lin escreveu:
> > 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>
>
> Thanks, applied.
I take that back, kfree()? Are you compile testing this?
CC /tmp/build/perf/util/expr.o
util/expr.c: In function ‘expr__ctx_new’:
util/expr.c:302:13: error: implicit declaration of function ‘IS_ERR’ [-Werror=implicit-function-declaration]
302 | if (IS_ERR(ctx->ids)) {
| ^~~~~~
util/expr.c:303:17: error: implicit declaration of function ‘kfree’; did you mean ‘free’? [-Werror=implicit-function-declaration]
303 | kfree(ctx);
| ^~~~~
| free
cc1: all warnings being treated as errors
I had to fix it applying this on top, please compile test your patches.
- Arnaldo
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index c94c9ea30d1abd6a..254601060b392c42 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>
@@ -300,7 +301,7 @@ struct expr_parse_ctx *expr__ctx_new(void)
ctx->ids = hashmap__new(key_hash, key_equal, NULL);
if (IS_ERR(ctx->ids)) {
- kfree(ctx);
+ free(ctx);
return NULL;
}
ctx->runtime = 0;
prev parent reply other threads:[~2021-12-13 13:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YbdF4FtPY77Y6faW@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox