aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/trace.c
diff options
context:
space:
mode:
authorMahircan Gul <mahircg@mpi-sws.org>2016-02-05 07:01:16 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-02-08 12:46:53 -0500
commit42dabcddf6995f50bd4acc1fad650fc6bb0a688a (patch)
treeaacbe2d5fe6c5555fb0e752240a5c2dc8ee740fa /litmus/trace.c
parent3b688190e1d840b8357aae765911f0f00621e26f (diff)
Free before setting NULL to prevent memory leak
Diffstat (limited to 'litmus/trace.c')
-rw-r--r--litmus/trace.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/litmus/trace.c b/litmus/trace.c
index 6b3e5f77cc5e..330d1e8240be 100644
--- a/litmus/trace.c
+++ b/litmus/trace.c
@@ -425,11 +425,13 @@ static int alloc_timestamp_buffer(struct ftdev* ftdev, unsigned int idx)
425 425
426static void free_timestamp_buffer(struct ftdev* ftdev, unsigned int idx) 426static void free_timestamp_buffer(struct ftdev* ftdev, unsigned int idx)
427{ 427{
428 struct ft_buffer* tmp = ftdev->minor[idx].buf;
429 smp_rmb();
428 ftdev->minor[idx].buf = NULL; 430 ftdev->minor[idx].buf = NULL;
429 /* Make sure all cores have actually seen buf == NULL before 431 /* Make sure all cores have actually seen buf == NULL before
430 * yanking out the mappings from underneath them. */ 432 * yanking out the mappings from underneath them. */
431 smp_wmb(); 433 smp_wmb();
432 free_ft_buffer(ftdev->minor[idx].buf); 434 free_ft_buffer(tmp);
433} 435}
434 436
435static ssize_t write_timestamp_from_user(struct ft_buffer* buf, size_t len, 437static ssize_t write_timestamp_from_user(struct ft_buffer* buf, size_t len,