From cd3978eda0f34229ccc8cbf917c5e3fe41887418 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 26 May 2020 15:26:24 +0300 Subject: glusterd: fix memory leak in glusterd_store_retrieve_bricks() Found with GCC's address sanitizer: ==67190==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24624 byte(s) in 6 object(s) allocated from: #0 0x7f62535c0837 in __interceptor_calloc (/usr/lib64/libasan.so.6+0xb0837) #1 0x7f62532a1690 in __gf_default_calloc glusterfs/mem-pool.h:122 #2 0x7f62532a20ca in __gf_calloc /path/to/glusterfs/libglusterfs/src/mem-pool.c:144 #3 0x7f62532c8128 in gf_store_iter_new /path/to/glusterfs/libglusterfs/src/store.c:511 #4 0x7f623e2f9ed7 in glusterd_store_retrieve_bricks /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:2389 Direct leak of 8208 byte(s) in 2 object(s) allocated from: #0 0x7f62535c0837 in __interceptor_calloc (/usr/lib64/libasan.so.6+0xb0837) #1 0x7f62532a1690 in __gf_default_calloc glusterfs/mem-pool.h:122 #2 0x7f62532a20ca in __gf_calloc /path/to/glusterfs/libglusterfs/src/mem-pool.c:144 #3 0x7f62532c8128 in gf_store_iter_new /path/to/glusterfs/libglusterfs/src/store.c:511 #4 0x7f623e2f9cf0 in glusterd_store_retrieve_bricks /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:2363 #5 0x7fff5cb70bcf ([stack]+0x15bcf) #6 0x7f623e309113 in glusterd_store_retrieve_volumes /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:3505 #7 0xfffeb96e61d () #8 0x7f623e4586d7 (/usr/lib64/glusterfs/9dev/xlator/mgmt/glusterd.so+0x2f86d7) Change-Id: I9b2a543dc095f4fa739cd664fd4d608bf8c87d60 Signed-off-by: Dmitry Antipov Fixes: #1263 --- xlators/mgmt/glusterd/src/glusterd-store.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 458df8dbd1d..6e02516d29d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -2642,6 +2642,13 @@ glusterd_store_retrieve_bricks(glusterd_volinfo_t *volinfo) brick_count++; } + if (gf_store_iter_destroy(tmpiter)) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_STORE_ITER_DESTROY_FAIL, + "Failed to destroy store iter"); + ret = -1; + goto out; + } + ret = gf_store_iter_new(volinfo->shandle, &tmpiter); if (ret) -- cgit