Re: [PATCH 3/3] trace-cmd: Check the return of get_file_content() before calling add_reset_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 12, 2019 at 9:19 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
>
> 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@xxxxxxxxxxx>
> ---

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


>  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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux