diff options
author | Susant Palai <spalai@redhat.com> | 2015-04-30 13:25:39 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-05-04 01:16:06 -0700 |
commit | c7bf5633276ee78e32ff79e5c0815b3f51e39500 (patch) | |
tree | 938a4164e4778efb565a493545bbe662ed2f743d /xlators | |
parent | 3527c6a7dfe435c3b6b8d89a325ae0603f2c08a1 (diff) |
dht: Add a null check before freeing dir_dfmeta and tmp_container
Change-Id: Ifbba6f340adfe2b4e3ad07260fbf4a25698ad8df
BUG: 1217949
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/10459
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index d471a71db89..ae5932f717f 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -32,6 +32,17 @@ idx %= sv_cnt; \ } +#define GF_FREE_DIR_DFMETA(dir_dfmeta) { \ + if (dir_dfmeta) { \ + GF_FREE (dir_dfmeta->head); \ + GF_FREE (dir_dfmeta->equeue); \ + GF_FREE (dir_dfmeta->iterator); \ + GF_FREE (dir_dfmeta->offset_var); \ + GF_FREE (dir_dfmeta->fetch_entries); \ + GF_FREE (dir_dfmeta); \ + } \ + } \ + void dht_set_global_defrag_error (gf_defrag_info_t *defrag, int ret) { @@ -42,6 +53,7 @@ dht_set_global_defrag_error (gf_defrag_info_t *defrag, int ret) UNLOCK (&defrag->lock); return; } + static int dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count, int32_t size, off_t offset, struct iobref *iobref) @@ -2029,8 +2041,11 @@ out: if (ret == 0) { *container = tmp_container; } else { - GF_FREE (tmp_container->parent_loc); - GF_FREE (tmp_container); + if (tmp_container) { + GF_FREE (tmp_container->df_entry); + GF_FREE (tmp_container->parent_loc); + GF_FREE (tmp_container); + } } if (xattr_rsp) @@ -2253,12 +2268,7 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc, ret = 0; out: - GF_FREE (dir_dfmeta->head); - GF_FREE (dir_dfmeta->equeue); - GF_FREE (dir_dfmeta->iterator); - GF_FREE (dir_dfmeta->offset_var); - GF_FREE (dir_dfmeta->fetch_entries); - GF_FREE (dir_dfmeta); + GF_FREE_DIR_DFMETA (dir_dfmeta); if (dict) dict_unref(dict); @@ -2464,7 +2474,6 @@ gf_defrag_start_crawl (void *data) int i = 0; int thread_index = 0; int err = 0; - int thread_status = 0; pthread_t tid[MAX_MIGRATOR_THREAD_COUNT]; this = data; @@ -2648,7 +2657,7 @@ out: /*Wait for all the threads to complete their task*/ for (i = 0; i < thread_index; i++) { - thread_status = pthread_join (tid[i], NULL); + pthread_join (tid[i], NULL); } if (defrag->queue) { |