All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] [PATCH 2/2] perf: Check return value of strdup
Date: Mon, 17 Sep 2012 01:48:16 +0300	[thread overview]
Message-ID: <20120916224816.GA3092@swordfish> (raw)
In-Reply-To: 1347805051-2889-2-git-send-email-namhyung@gmail.com

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On (09/16/12 23:17), Namhyung Kim wrote:
> The strdup() can return NULL so that the result should be checked.
> 
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---

looks good to me, thank you.

	-ss

>  src/perf/perf.cpp |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
> index c8ba7a8..35b4017 100644
> --- a/src/perf/perf.cpp
> +++ b/src/perf/perf.cpp
> @@ -145,6 +145,11 @@ void perf_event::set_event_name(const char *event_name)
>  	if (name)
>  		free(name);
>  	name = strdup(event_name);
> +	if (!name) {
> +		fprintf(stderr, "failed to allocate event name\n");
> +		return;
> +	}
> +
>  	char *c;
>  
>  	c = strchr(name, ':');

             reply	other threads:[~2012-09-16 22:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-16 22:48 Sergey Senozhatsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-09-17 15:21 [Powertop] [PATCH 2/2] perf: Check return value of strdup Chris Ferron
2012-09-16 14:17 Namhyung Kim

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=20120916224816.GA3092@swordfish \
    --to=powertop@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.