From: German Gomez <german.gomez@arm.com>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
James Clark <james.clark@arm.com>,
Kan Liang <kan.liang@linux.intel.com>,
Song Liu <songliubraving@fb.com>,
Jin Yao <yao.jin@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg
Date: Sun, 12 Dec 2021 15:37:40 +0000 [thread overview]
Message-ID: <5f4cf208-386e-6a22-5b05-185ed6cdf069@arm.com> (raw)
In-Reply-To: <864ad02d-6afe-791c-f742-56582b633482@arm.com>
On 12/12/2021 14:55, German Gomez wrote:
> Hi Miaoqian,
>
> On 12/12/2021 04:23, Miaoqian Lin wrote:
>> The hashmap__new() function does not return NULL on errors. It returns
>> ERR_PTR(-ENOMEM). Using IS_ERR() to check the return value
>> to fix this.
>>
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
>> tools/perf/util/stat.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
>> index 09ea334586f2..a77052680087 100644
>> --- a/tools/perf/util/stat.c
>> +++ b/tools/perf/util/stat.c
>> @@ -311,8 +311,8 @@ static int check_per_pkg(struct evsel *counter,
>>
>> if (!mask) {
>> mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
>> - if (!mask)
>> - return -ENOMEM;
>> + if (IS_ERR(mask))
>> + return PTR_ERR(mask);
Also (sorry, I haven't tried/tested the patch yet) is this return
necessary? To me it seems it's still ok to keep the "return -ENOMEM".
> I see that callers to "ids__new" are also missing these checks. Did you
> consider patching those also?
>
> Thanks,
> German
>
>>
>> counter->per_pkg_mask = mask;
>> }
next prev parent reply other threads:[~2021-12-12 15:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 4:23 [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg Miaoqian Lin
2021-12-12 14:55 ` German Gomez
2021-12-12 15:37 ` German Gomez [this message]
2021-12-13 7:09 ` [PATCH] perf expr: Fix return value of ids__new Miaoqian Lin
2021-12-13 13:13 ` German Gomez
2021-12-13 16:02 ` German Gomez
2021-12-13 13:57 ` German Gomez
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=5f4cf208-386e-6a22-5b05-185ed6cdf069@arm.com \
--to=german.gomez@arm.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=james.clark@arm.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.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 \
--cc=songliubraving@fb.com \
--cc=yao.jin@linux.intel.com \
/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