Re: [PATCH] perf: fix missing event name init for default event

From: Stephane Eranian
Date: Tue Jun 07 2011 - 11:45:30 EST


On Mon, Jun 6, 2011 at 7:32 PM, Ingo Molnar <mingo@xxxxxxx> wrote:
>
> * Stephane Eranian <eranian@xxxxxxxxxx> wrote:
>
>> @@ -87,6 +87,13 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
>> Â Â Â if (evsel == NULL)
>> Â Â Â Â Â Â Â return -ENOMEM;
>>
>> + Â Â /* use strdup() because free(evsel) assumes name is allocated */
>> + Â Â evsel->name = strdup("cycles");
>> + Â Â if (!evsel->name) {
>> + Â Â Â Â Â Â free(evsel);
>> + Â Â Â Â Â Â return -ENOMEM;
>> + Â Â }
>> +
>> Â Â Â perf_evlist__add(evlist, evsel);
>> Â Â Â return 0;
>> Â}
>
> Hm, nice fix, but this function should really follow the standard
> exception tear-down sequence pattern we use in the kernel:
>
Fine, I can respin that patch.

> Â Â Â Âif (evsel == NULL)
> Â Â Â Â Â Â Â Âgoto err;
>
> Â Â Â Â...
>
> Â Â Â Âif (!evsel->name)
> Â Â Â Â Â Â Â Âgoto err_free;
>
> Â Â Â Â...
>
> Â Â Â Âreturn 0;
>
> err_free:
> Â Â Â Âfree(evsel);
> err:
> Â Â Â Âreturn -ENOMEM;
>
> Thanks,
>
> Â Â Â ÂIngo
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/