summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-metadata.c
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-11-25 11:01:01 +0530
committerAmar Tumballi <amarts@redhat.com>2018-11-28 03:29:32 +0000
commitbbf1b9090b6b51292afab4af4479ef2d4ca61265 (patch)
treeabf893678ea472e53ef180515a7c00b479c68a9e /xlators/storage/posix/src/posix-metadata.c
parent6d69a663497ba2bb90b42eae8384cc57d6e4b283 (diff)
posix: fix memory leak
Direct leak of 609960 byte(s) in 4485 object(s) allocated from: #0 0x7f0d719bea50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50) #1 0x7f0d716dc08f in __gf_calloc ../../../libglusterfs/src/mem-pool.c:111 #2 0x7f0d5d41d9b2 in __posix_get_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:240 #3 0x7f0d5d41dd6b in posix_get_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:317 #4 0x7f0d5d39e855 in posix_fdstat ../../../../../xlators/storage/posix/src/posix-helpers.c:685 #5 0x7f0d5d3d65ec in posix_create ../../../../../xlators/storage/posix/src/posix-entry-ops.c:2173 Direct leak of 609960 byte(s) in 4485 object(s) allocated from: #0 0x7f0d719bea50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50) #1 0x7f0d716dc08f in __gf_calloc ../../../libglusterfs/src/mem-pool.c:111 #2 0x7f0d5d41ced2 in posix_set_mdata_xattr ../../../../../xlators/storage/posix/src/posix-metadata.c:359 #3 0x7f0d5d41e70f in posix_set_ctime ../../../../../xlators/storage/posix/src/posix-metadata.c:616 #4 0x7f0d5d3d662c in posix_create ../../../../../xlators/storage/posix/src/posix-entry-ops.c:2181 We were freeing only the first context in inode during forget, and not the second. updates: bz#1633930 Change-Id: Ib61b4453aa3d2039d6ce660f52ef45390539b9db Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-metadata.c')
-rw-r--r--xlators/storage/posix/src/posix-metadata.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c
index 62fc328..99b49ff 100644
--- a/xlators/storage/posix/src/posix-metadata.c
+++ b/xlators/storage/posix/src/posix-metadata.c
@@ -269,6 +269,7 @@ __posix_get_mdata_xattr(xlator_t *this, const char *real_path, int _fd,
*/
if (stbuf && op_errno != ENOENT) {
ret = 0;
+ GF_FREE(mdata);
goto out;
} else {
/* This case should not be hit. If it hits,
@@ -342,6 +343,7 @@ posix_set_mdata_xattr(xlator_t *this, const char *real_path, int fd,
posix_mdata_t *mdata = NULL;
int ret = -1;
int op_errno = 0;
+ bool free_mdata = false;
GF_VALIDATE_OR_GOTO("posix", this, out);
GF_VALIDATE_OR_GOTO(this->name, inode, out);
@@ -412,6 +414,8 @@ posix_set_mdata_xattr(xlator_t *this, const char *real_path, int fd,
mdata->mtime.tv_nsec = time->tv_nsec;
__inode_ctx_set1(inode, this, (uint64_t *)&mdata);
+ } else {
+ free_mdata = true;
}
}
@@ -485,6 +489,9 @@ out:
stbuf->ia_atime_nsec = mdata->atime.tv_nsec;
}
+ if (free_mdata)
+ GF_FREE(mdata);
+
return ret;
}