Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1605763 > unrolled thread

[PATCH] trace-cmd: Fix segmentation fault in trace-snapshot

Started byJohn Kacur <jkacur@redhat.com>
First post2017-03-21 17:20 +0100
Last post2017-03-21 19:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] trace-cmd: Fix segmentation fault in trace-snapshot John Kacur <jkacur@redhat.com> - 2017-03-21 17:20 +0100
    Re: [PATCH] trace-cmd: Fix segmentation fault in trace-snapshot Steven Rostedt <rostedt@goodmis.org> - 2017-03-21 19:40 +0100

#1605763 — [PATCH] trace-cmd: Fix segmentation fault in trace-snapshot

FromJohn Kacur <jkacur@redhat.com>
Date2017-03-21 17:20 +0100
Subject[PATCH] trace-cmd: Fix segmentation fault in trace-snapshot
Message-ID<tnuFP-5IV-13@gated-at.bofh.it>
To reproduce the problem:

  plugin 'wakeup'
trace-cmd: Device or resource busy
  Segmentation fault (core dumped)

When the user triggers a condition such as EBUSY the program should die
gracefully. The problem here is simply caused by an extra conversion
specifier in "die" in the write_file function

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 trace-snapshot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/trace-snapshot.c b/trace-snapshot.c
index 9d3608c49563..771b065ccfa4 100644
--- a/trace-snapshot.c
+++ b/trace-snapshot.c
@@ -42,7 +42,8 @@ static void write_file(const char *name, char *val)
 
 	n = write(fd, val, strlen(val));
 	if (n < 0)
-		die("failed to write '%d' to %s\n", path);
+		die("failed to write to %s\n", path);
+
 	tracecmd_put_tracing_file(path);
 	close(fd);
 }
-- 
2.5.5

[toc] | [next] | [standalone]


#1605886

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-21 19:40 +0100
Message-ID<tnwRj-779-15@gated-at.bofh.it>
In reply to#1605763
On Tue, 21 Mar 2017 17:11:53 +0100
John Kacur <jkacur@redhat.com> wrote:

> To reproduce the problem:
> 
>   plugin 'wakeup'
> trace-cmd: Device or resource busy
>   Segmentation fault (core dumped)
> 
> When the user triggers a condition such as EBUSY the program should
> die gracefully. The problem here is simply caused by an extra
> conversion specifier in "die" in the write_file function

Thanks John!

I'm currently traveling but I'll apply this when I get a chance.

-- Steve

> 
> Signed-off-by: John Kacur <jkacur@redhat.com>
> ---
>  trace-snapshot.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/trace-snapshot.c b/trace-snapshot.c
> index 9d3608c49563..771b065ccfa4 100644
> --- a/trace-snapshot.c
> +++ b/trace-snapshot.c
> @@ -42,7 +42,8 @@ static void write_file(const char *name, char *val)
>  
>  	n = write(fd, val, strlen(val));
>  	if (n < 0)
> -		die("failed to write '%d' to %s\n", path);
> +		die("failed to write to %s\n", path);
> +
>  	tracecmd_put_tracing_file(path);
>  	close(fd);
>  }

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web