blob: 3e2c4e1e68d952a5277d9a31355198e7da96ff60 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From e4cad900994cf286d971796a947fea782dfc6651 Mon Sep 17 00:00:00 2001
2From: Francis Giraldeau <francis.giraldeau@gmail.com>
3Date: Mon, 15 Jun 2015 11:43:02 -0400
4Subject: [PATCH] Fix invalid pointer free with trace collection
5
6Upstream-Status: Submitted
7
8Patch proposed by Li RongQing related to bug# 790
9
10Signed-off-by: Mikael Beckius <mikael.beckius@windriver.com>
11Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
12---
13 lib/context.c | 8 +++-----
14 1 file changed, 3 insertions(+), 5 deletions(-)
15
16diff --git a/lib/context.c b/lib/context.c
17index 45aab34..8d3770f 100644
18--- a/lib/context.c
19+++ b/lib/context.c
20@@ -79,7 +79,7 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
21 struct bt_trace_descriptor *td;
22 struct bt_format *fmt;
23 struct bt_trace_handle *handle;
24- int ret, closeret;
25+ int ret;
26
27 if (!ctx || !format_name || (!path && !stream_list))
28 return -EINVAL;
29@@ -159,10 +159,8 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
30 return handle->id;
31
32 error:
33- closeret = fmt->close_trace(td);
34- if (closeret) {
35- fprintf(stderr, "Error in close_trace callback\n");
36- }
37+ if (handle)
38+ bt_context_remove_trace(ctx, handle->id);
39 end:
40 return ret;
41 }
42--
431.9.1
44