All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 07/10] perf sort: Check return value of strdup()
Date: Fri, 11 Jan 2013 02:17:45 -0300	[thread overview]
Message-ID: <20130111051745.GF3054@ghostprotocols.net> (raw)
In-Reply-To: <1356599507-14226-8-git-send-email-namhyung@kernel.org>

Em Thu, Dec 27, 2012 at 06:11:44PM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> When setup_sorting() is called, 'str' is passed to strtok_r() but it's
> not checked to have a valid pointer.  As strtok_r() accepts NULL
> pointer on a first argument and use the third argument in that case,
> it can cause a trouble since our third argument, tmp, is not
> initialized.

Ok, but calling exit from here? Better to check it at the callers and
propagate the error, letting things like TUI/gui exit routines to
execute.
 
> Cc: Stephane Eranian <eranian@google.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/sort.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index c02964cabdd0..9f827e25a2b5 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -552,6 +552,11 @@ void setup_sorting(const char * const usagestr[], const struct option *opts)
>  {
>  	char *tmp, *tok, *str = strdup(sort_order);
>  
> +	if (str == NULL) {
> +		error("Not enough memory to setup sort keys");
> +		exit(-1);
> +	}
> +
>  	for (tok = strtok_r(str, ", ", &tmp);
>  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
>  		if (sort_dimension__add(tok) < 0) {
> -- 
> 1.7.11.7

  reply	other threads:[~2013-01-11 21:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-27  9:11 [PATCHSET 00/10] perf tools: Cleanups and bug fixes on sort keys Namhyung Kim
2012-12-27  9:11 ` [PATCH 01/10] perf sort: Move misplaced sort entry functions Namhyung Kim
2013-01-25 11:37   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 02/10] perf sort: Get rid of unnecessary __maybe_unused Namhyung Kim
2013-01-25 11:38   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 03/10] perf sort: Fix --sort pid output Namhyung Kim
2013-01-25 11:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 04/10] perf sort: Align cpu column to right Namhyung Kim
2013-01-25 11:41   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 05/10] perf sort: Calculate parent column width too Namhyung Kim
2013-01-25 11:42   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 06/10] perf sort: Drop ip_[lr] arguments from _sort__sym_cmp() Namhyung Kim
2013-01-11  5:16   ` Arnaldo Carvalho de Melo
2012-12-27  9:11 ` [PATCH 07/10] perf sort: Check return value of strdup() Namhyung Kim
2013-01-11  5:17   ` Arnaldo Carvalho de Melo [this message]
2013-01-13  8:43     ` Namhyung Kim
2013-01-16 18:38       ` Arnaldo Carvalho de Melo
2012-12-27  9:11 ` [PATCH 08/10] perf sort: Clean up sort__first_dimension setting Namhyung Kim
2013-01-25 11:43   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 09/10] perf sort: Separate out branch stack specific sort keys Namhyung Kim
2013-01-25 11:44   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-27  9:11 ` [PATCH 10/10] perf report: Update documentation for " Namhyung Kim
2013-01-25 11:45   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-12-28 11:21 ` [PATCHSET 00/10] perf tools: Cleanups and bug fixes on " Jiri Olsa

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=20130111051745.GF3054@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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.