Re: [PATCH] perf: fix missing event name init for default event
From: Ingo Molnar
Date: Mon Jun 06 2011 - 13:33:12 EST
* 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:
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/