[PATCH 08/11] libtraceeval task-eval: Only release results if found

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

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

In set_process_data(), the results are release even if they were not
found. But when they are not found, results is undefined.

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 samples/task-eval.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/samples/task-eval.c b/samples/task-eval.c
index aa61ec38244f..79039580ce78 100644
--- a/samples/task-eval.c
+++ b/samples/task-eval.c
@@ -348,8 +348,10 @@ void set_process_data(struct task_data *tdata, const char *comm, void *data)
 	int ret;
 
 	ret = traceeval_query(tdata->teval_tasks, keys, &results);
-	if (ret > 0)
-		goto out; /* It already exists ? */
+	if (ret > 0) {
+		traceeval_results_release(tdata->teval_tasks, results);
+		return; /* It already exists ? */
+	}
 	if (ret < 0)
 		pdie("Could not query process data");
 
@@ -358,9 +360,6 @@ void set_process_data(struct task_data *tdata, const char *comm, void *data)
 	ret = traceeval_insert(tdata->teval_tasks, keys, new_vals);
 	if (ret < 0)
 		pdie("Failed to set process data");
-
- out:
-	traceeval_results_release(tdata->teval_tasks, results);
 }
 
 static struct process_data *alloc_pdata(struct task_data *tdata, const char *comm)
-- 
2.42.0





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

  Powered by Linux