From 647e5a6fd27f570900241d5a1961e91eabc98047 Mon Sep 17 00:00:00 2001 From: Dave Goodell Date: Wed, 23 Oct 2013 15:51:44 +0000 Subject: [PATCH] rcache/vma: fix module finalization memory leaks Reviewed-by: Jeff Squyres This commit was SVN r29486. --- ompi/mca/rcache/vma/rcache_vma.c | 5 ++++- ompi/mca/rcache/vma/rcache_vma_tree.c | 10 ++++++++++ ompi/mca/rcache/vma/rcache_vma_tree.h | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ompi/mca/rcache/vma/rcache_vma.c b/ompi/mca/rcache/vma/rcache_vma.c index 3770680c7e..5acc933192 100644 --- a/ompi/mca/rcache/vma/rcache_vma.c +++ b/ompi/mca/rcache/vma/rcache_vma.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006 Voltaire. All rights reserved. - * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2009 IBM Corporation. All rights reserved. * Copyright (c) 2013 NVIDIA Corporation. All rights reserved. * @@ -169,6 +169,9 @@ int mca_rcache_vma_clean(struct mca_rcache_base_module_t* rcache) */ void mca_rcache_vma_finalize(struct mca_rcache_base_module_t* rcache) { + OBJ_DESTRUCT(&rcache->lock); + mca_rcache_vma_tree_finalize((mca_rcache_vma_module_t *)rcache); + free(rcache); } void mca_rcache_vma_dump_range(struct mca_rcache_base_module_t* rcache, diff --git a/ompi/mca/rcache/vma/rcache_vma_tree.c b/ompi/mca/rcache/vma/rcache_vma_tree.c index befe79ee6d..08ff991de0 100644 --- a/ompi/mca/rcache/vma/rcache_vma_tree.c +++ b/ompi/mca/rcache/vma/rcache_vma_tree.c @@ -16,6 +16,7 @@ * Copyright (c) 2009 IBM Corporation. All rights reserved. * Copyright (c) 2013 NVIDIA Corporation. All rights reserved. * + * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -266,6 +267,15 @@ int mca_rcache_vma_tree_init(mca_rcache_vma_module_t* rcache) mca_rcache_vma_tree_node_compare); } +void mca_rcache_vma_tree_finalize(mca_rcache_vma_module_t* rcache) +{ + ompi_rb_tree_init(&rcache->rb_tree, + mca_rcache_vma_tree_node_compare); + OBJ_DESTRUCT(&rcache->vma_delete_list); + OBJ_DESTRUCT(&rcache->vma_list); + OBJ_DESTRUCT(&rcache->rb_tree); +} + mca_mpool_base_registration_t *mca_rcache_vma_tree_find( mca_rcache_vma_module_t* vma_rcache, unsigned char *base, unsigned char *bound) diff --git a/ompi/mca/rcache/vma/rcache_vma_tree.h b/ompi/mca/rcache/vma/rcache_vma_tree.h index 4d813ca446..eecc78f9f7 100644 --- a/ompi/mca/rcache/vma/rcache_vma_tree.h +++ b/ompi/mca/rcache/vma/rcache_vma_tree.h @@ -14,6 +14,7 @@ * Copyright (c) 2006 Voltaire. All rights reserved. * Copyright (c) 2009 IBM Corporation. All rights reserved. * + * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -63,6 +64,11 @@ OBJ_CLASS_DECLARATION(mca_rcache_vma_t); */ int mca_rcache_vma_tree_init(mca_rcache_vma_module_t* rcache); +/* + * clean up the vma tree + */ +void mca_rcache_vma_tree_finalize(mca_rcache_vma_module_t* rcache); + /** * Returns the item in the vma tree */