The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, acme@redhat.com
Subject: Re: [PATCH] perf: fix missing event name init for default event
Date: Mon, 6 Jun 2011 19:32:51 +0200	[thread overview]
Message-ID: <20110606173251.GJ2391@elte.hu> (raw)
In-Reply-To: <20110606151024.GA9464@quad>


* Stephane Eranian <eranian@google.com> 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

  reply	other threads:[~2011-06-06 17:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 15:10 [PATCH] perf: fix missing event name init for default event Stephane Eranian
2011-06-06 17:32 ` Ingo Molnar [this message]
2011-06-07 15:45   ` Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110606173251.GJ2391@elte.hu \
    --to=mingo@elte.hu \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox