lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 12 Dec 2021 15:37:40 +0000
From:   German Gomez <german.gomez@....com>
To:     Miaoqian Lin <linmq006@...il.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        James Clark <james.clark@....com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Song Liu <songliubraving@...com>,
        Jin Yao <yao.jin@...ux.intel.com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg


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@...il.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;
>>  	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ