Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1414889 > unrolled thread
| Started by | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| First post | 2016-06-06 13:00 +0200 |
| Last post | 2016-06-07 09:50 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done Taeung Song <treeze.taeung@gmail.com> - 2016-06-06 13:00 +0200
Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-06 22:30 +0200
Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done Taeung Song <treeze.taeung@gmail.com> - 2016-06-06 23:40 +0200
Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done Taeung Song <treeze.taeung@gmail.com> - 2016-06-07 09:50 +0200
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2016-06-06 13:00 +0200 |
| Subject | [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done |
| Message-ID | <rH0qe-3MT-31@gated-at.bofh.it> |
Because of die() at perf_parse_file() a config set was freed
in collect_config(), if failed.
But it is natural to free a config set after collect_config() is done
when some problems happened.
So, in case of failure, lastly free a config set at perf_config_set__new()
instead of freeing the config set in collect_config().
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/config.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index b500737..d013f90 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -639,7 +639,6 @@ static int collect_config(const char *var, const char *value,
out_free:
free(key);
- perf_config_set__delete(set);
return -1;
}
@@ -649,7 +648,8 @@ struct perf_config_set *perf_config_set__new(void)
if (set) {
INIT_LIST_HEAD(&set->sections);
- perf_config(collect_config, set);
+ if (perf_config(collect_config, set) < 0)
+ perf_config_set__delete(set);
}
return set;
--
2.5.0
[toc] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-06-06 22:30 +0200 |
| Subject | Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done |
| Message-ID | <rH9jP-1cX-9@gated-at.bofh.it> |
| In reply to | #1414889 |
Em Mon, Jun 06, 2016 at 07:52:53PM +0900, Taeung Song escreveu:
> Because of die() at perf_parse_file() a config set was freed
> in collect_config(), if failed.
> But it is natural to free a config set after collect_config() is done
> when some problems happened.
>
> So, in case of failure, lastly free a config set at perf_config_set__new()
> instead of freeing the config set in collect_config().
>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
> tools/perf/util/config.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
> index b500737..d013f90 100644
> --- a/tools/perf/util/config.c
> +++ b/tools/perf/util/config.c
> @@ -639,7 +639,6 @@ static int collect_config(const char *var, const char *value,
>
> out_free:
> free(key);
> - perf_config_set__delete(set);
> return -1;
> }
>
> @@ -649,7 +648,8 @@ struct perf_config_set *perf_config_set__new(void)
>
> if (set) {
> INIT_LIST_HEAD(&set->sections);
> - perf_config(collect_config, set);
> + if (perf_config(collect_config, set) < 0)
> + perf_config_set__delete(set);
> }
>
> return set;
You can't do that, there is something missing, without looking at the
code I think you need:
if (set) {
INIT_LIST_HEAD(&set->sections);
- perf_config(collect_config, set);
+ if (perf_config(collect_config, set) < 0) {
+ perf_config_set__delete(set);
+ set = NULL;
+ }
}
return set;
No?
- Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2016-06-06 23:40 +0200 |
| Subject | Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done |
| Message-ID | <rHapA-1UM-5@gated-at.bofh.it> |
| In reply to | #1415418 |
On 06/07/2016 05:23 AM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jun 06, 2016 at 07:52:53PM +0900, Taeung Song escreveu:
>> Because of die() at perf_parse_file() a config set was freed
>> in collect_config(), if failed.
>> But it is natural to free a config set after collect_config() is done
>> when some problems happened.
>>
>> So, in case of failure, lastly free a config set at perf_config_set__new()
>> instead of freeing the config set in collect_config().
>>
>> Cc: Namhyung Kim <namhyung@kernel.org>
>> Cc: Jiri Olsa <jolsa@redhat.com>
>> Cc: Masami Hiramatsu <mhiramat@kernel.org>
>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
>> ---
>> tools/perf/util/config.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
>> index b500737..d013f90 100644
>> --- a/tools/perf/util/config.c
>> +++ b/tools/perf/util/config.c
>> @@ -639,7 +639,6 @@ static int collect_config(const char *var, const char *value,
>>
>> out_free:
>> free(key);
>> - perf_config_set__delete(set);
>> return -1;
>> }
>>
>> @@ -649,7 +648,8 @@ struct perf_config_set *perf_config_set__new(void)
>>
>> if (set) {
>> INIT_LIST_HEAD(&set->sections);
>> - perf_config(collect_config, set);
>> + if (perf_config(collect_config, set) < 0)
>> + perf_config_set__delete(set);
>> }
>>
>> return set;
>
> You can't do that, there is something missing, without looking at the
> code I think you need:
>
> if (set) {
> INIT_LIST_HEAD(&set->sections);
> - perf_config(collect_config, set);
> + if (perf_config(collect_config, set) < 0) {
> + perf_config_set__delete(set);
> + set = NULL;
> + }
> }
>
> return set;
>
> No?
>
Granted
Sorry for missing above..
I modified using 'return NULL;' instead of 'set = NULL;' as below
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index c73f1c4..cb749d3 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -643,7 +643,6 @@ static int collect_config(const char *var, const
char *value,
out_free:
free(key);
- perf_config_set__delete(set);
return -1;
}
@@ -653,7 +652,10 @@ struct perf_config_set *perf_config_set__new(void)
if (set) {
INIT_LIST_HEAD(&set->sections);
- perf_config(collect_config, set);
+ if (perf_config(collect_config, set) < 0) {
+ perf_config_set__delete(set);
+ return NULL;
+ }
}
return set;
Because in near future, perf_config_set__delete() will use zfree().
will send changed this patch soon !
Thank you for your review :)
Taeung
[toc] | [prev] | [next] | [standalone]
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2016-06-07 09:50 +0200 |
| Subject | Re: [BUGFIX][PATCH v6 2/9] perf config: If collect_config() is failed, finally free a config set after it is done |
| Message-ID | <rHjVT-8cE-11@gated-at.bofh.it> |
| In reply to | #1415493 |
On 06/07/2016 06:37 AM, Taeung Song wrote:
>
>
> On 06/07/2016 05:23 AM, Arnaldo Carvalho de Melo wrote:
>> Em Mon, Jun 06, 2016 at 07:52:53PM +0900, Taeung Song escreveu:
>>> Because of die() at perf_parse_file() a config set was freed
>>> in collect_config(), if failed.
>>> But it is natural to free a config set after collect_config() is done
>>> when some problems happened.
>>>
>>> So, in case of failure, lastly free a config set at
>>> perf_config_set__new()
>>> instead of freeing the config set in collect_config().
>>>
>>> Cc: Namhyung Kim <namhyung@kernel.org>
>>> Cc: Jiri Olsa <jolsa@redhat.com>
>>> Cc: Masami Hiramatsu <mhiramat@kernel.org>
>>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>>> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
>>> ---
>>> tools/perf/util/config.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
>>> index b500737..d013f90 100644
>>> --- a/tools/perf/util/config.c
>>> +++ b/tools/perf/util/config.c
>>> @@ -639,7 +639,6 @@ static int collect_config(const char *var, const
>>> char *value,
>>>
>>> out_free:
>>> free(key);
>>> - perf_config_set__delete(set);
>>> return -1;
>>> }
>>>
>>> @@ -649,7 +648,8 @@ struct perf_config_set *perf_config_set__new(void)
>>>
>>> if (set) {
>>> INIT_LIST_HEAD(&set->sections);
>>> - perf_config(collect_config, set);
>>> + if (perf_config(collect_config, set) < 0)
>>> + perf_config_set__delete(set);
>>> }
>>>
>>> return set;
>>
>> You can't do that, there is something missing, without looking at the
>> code I think you need:
>>
>> if (set) {
>> INIT_LIST_HEAD(&set->sections);
>> - perf_config(collect_config, set);
>> + if (perf_config(collect_config, set) < 0) {
>> + perf_config_set__delete(set);
>> + set = NULL;
>> + }
>> }
>>
>> return set;
>>
>> No?
>>
>
> Granted
> Sorry for missing above..
>
> I modified using 'return NULL;' instead of 'set = NULL;' as below
>
> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
> index c73f1c4..cb749d3 100644
> --- a/tools/perf/util/config.c
> +++ b/tools/perf/util/config.c
> @@ -643,7 +643,6 @@ static int collect_config(const char *var, const
> char *value,
>
> out_free:
> free(key);
> - perf_config_set__delete(set);
> return -1;
> }
>
> @@ -653,7 +652,10 @@ struct perf_config_set *perf_config_set__new(void)
>
> if (set) {
> INIT_LIST_HEAD(&set->sections);
> - perf_config(collect_config, set);
> + if (perf_config(collect_config, set) < 0) {
> + perf_config_set__delete(set);
> + return NULL;
> + }
> }
>
> return set;
>
> Because in near future, perf_config_set__delete() will use zfree().
>
> will send changed this patch soon !
> Thank you for your review :)
>
Hum.. my answer was stupid.
There isn't difference between 'return NULL;' and 'set = NULL;'
as a result at perf_config_set__new().
And zfree() at perf_config_set__delete() aren't related to this situation..
Anyway.. I'll send v7 with changed this patch as you said!!
Thanks,
Taeung
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web