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]
Message-ID: <554DB45D.3040507@huawei.com>
Date:	Sat, 9 May 2015 15:16:45 +0800
From:	He Kuang <hekuang@...wei.com>
To:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	<a.p.zijlstra@...llo.nl>, <acme@...nel.org>, <jolsa@...nel.org>,
	<mingo@...hat.com>
CC:	<wangnan0@...wei.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] perf probe: Remove length limitation for showing
 available variables


On 2015/5/8 22:17, Masami Hiramatsu wrote:
> On 2015/05/08 21:23, He Kuang wrote:
>> Use struct strbuf instead of bare char[] to remove the length limitation
>> of variables in variable_list, so they will not disappear due to
>> overlength, and make preparation for adding more description for
>> variables.
> Looks good to me, except one memory leak. please see below.

Oh yes, thanks!
>>  }
>>  
>> -#define MAX_VAR_LEN 64
>> -
>>  /* Collect available variables in this scope */
>>  static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
>>  {
>>  	struct available_var_finder *af = data;
>>  	struct variable_list *vl;
>> -	char buf[MAX_VAR_LEN];
>> +	struct strbuf buf;
>>  	int tag, ret;
>>  
>>  	vl = &af->vls[af->nvls - 1];
>> +	strbuf_init(&buf, 64);
>>  
>>  	tag = dwarf_tag(die_mem);
>>  	if (tag == DW_TAG_formal_parameter ||
>> @@ -1257,10 +1256,13 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
>>  						af->pf.fb_ops, &af->pf.sp_die,
>>  						NULL);
>>  		if (ret == 0) {

strbuf_init() should be called here to avoid useless malloc.

>> -			ret = die_get_varname(die_mem, buf, MAX_VAR_LEN);
>> -			pr_debug2("Add new var: %s\n", buf);
>> -			if (ret > 0)
>> -				strlist__add(vl->vars, buf);
>> +			ret = die_get_varname(die_mem, &buf);
>> +			pr_debug2("Add new var: %s\n", buf.buf);
>> +			if (ret == 0) {
>> +				strlist__add(vl->vars,
>> +					strbuf_detach(&buf, NULL));
>> +			}
>> +			strbuf_release(&buf);
> It seems that this strbuf_release() should be called in any case,
> since strbuf_init already allocated buffer.
>
>>  		}
>>  	}
> so here is the good place to call, isn't it?
>
> Thank you,
>
>>  
>>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ