diff options
author | Mahircan Gul <mahircg@mpi-sws.org> | 2016-02-05 07:01:16 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-02-08 12:46:53 -0500 |
commit | 42dabcddf6995f50bd4acc1fad650fc6bb0a688a (patch) | |
tree | aacbe2d5fe6c5555fb0e752240a5c2dc8ee740fa | |
parent | 3b688190e1d840b8357aae765911f0f00621e26f (diff) |
Free before setting NULL to prevent memory leak
-rw-r--r-- | litmus/trace.c | 4 |
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 | ||
426 | static void free_timestamp_buffer(struct ftdev* ftdev, unsigned int idx) | 426 | static 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 | ||
435 | static ssize_t write_timestamp_from_user(struct ft_buffer* buf, size_t len, | 437 | static ssize_t write_timestamp_from_user(struct ft_buffer* buf, size_t len, |