Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org"  <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 3/3] trace-cmd: Check the return of get_file_content() before calling add_reset_file()
Date: Thu, 13 Jun 2019 14:51:48 +0000
Message-ID: <CACqStod__XjWd7sk4oz2+E-DmQEHvT1kgKvU4sR-Kew8aki-zQ@mail.gmail.com> (raw)
In-Reply-To: <20190612182019.169932649@goodmis.org>

On Wed, Jun 12, 2019 at 9:19 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> If get_file_content() returns NULL, because the file does not exist or for
> any other reason, it will cause add_reset_file() to trigger a SEGSEGV due to
> using a NULL pointer. Only call add_reset_file() if get_file_content()
> actually returns something.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---

Looks OK.
Reviewed-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>


>  tracecmd/trace-record.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 2d716a81acbf..5dc6f17aa743 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -270,8 +270,10 @@ static void reset_save_file(const char *file, int prio)
>         char *content;
>
>         content = get_file_content(file);
> -       add_reset_file(file, content, prio);
> -       free(content);
> +       if (content) {
> +               add_reset_file(file, content, prio);
> +               free(content);
> +       }
>  }
>
>  /*
> --
> 2.20.1
>
>


--

Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 18:19 [PATCH 0/3] trace-cmd: Fix some bugs that include issues with --max-graph-depth Steven Rostedt
2019-06-12 18:19 ` [PATCH 1/3] trace-cmd: Fix typo in Makefile bidr to bdir Steven Rostedt
2019-06-13 14:40   ` Tzvetomir Stoyanov
2019-06-12 18:19 ` [PATCH 2/3] trace-cmd: Have --max-graph-depth only be part of instance Steven Rostedt
2019-06-13 14:48   ` Tzvetomir Stoyanov
2019-06-12 18:19 ` [PATCH 3/3] trace-cmd: Check the return of get_file_content() before calling add_reset_file() Steven Rostedt
2019-06-13 14:51   ` Tzvetomir Stoyanov [this message]
2019-06-13 14:51 ` [PATCH 0/3] trace-cmd: Fix some bugs that include issues with --max-graph-depth Slavomir Kaslev
2019-06-13 14:56   ` Steven Rostedt

Reply instructions:

You may reply publically 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=CACqStod__XjWd7sk4oz2+E-DmQEHvT1kgKvU4sR-Kew8aki-zQ@mail.gmail.com \
    --to=tstoyanov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.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

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org linux-trace-devel@archiver.kernel.org
	public-inbox-index linux-trace-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox