summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-12-19 09:45:42 +0530
committerAmar Tumballi <amarts@redhat.com>2018-12-20 06:26:37 +0000
commite1f92176a8d372e99386c0f007d6a38c0a54ca5b (patch)
tree4a84a104088b4e6d17a2d291230335abcdb23835 /libglusterfs
parent8cde14a537f0112400744d518ed196eb8fa232f2 (diff)
all: handle USE_AFTER_FREE warnings
* we shouldn't be using 'local' after DHT_STACK_UNWIND() as it frees the content of local. Add a 'goto out' or similar logic to handle the situation. * fix possible overlook of unref(dict), instead of unref(xdata). * make coverity happy by re-ordering unref in meta-defaults. * gfid-access: re-order dictionary allocation so we don't have to do a extra unref. * other obvious errors reported. updates: bz#789278 Change-Id: If05961ee946b0c4868df19861d7e4a927a2a2489 Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c10
-rw-r--r--libglusterfs/src/rbthash.c1
2 files changed, 8 insertions, 3 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 985e7580050..b6e4fbecf8a 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3568,17 +3568,21 @@ gf_is_local_addr(char *hostname)
}
for (res = result; res != NULL; res = res->ai_next) {
- gf_msg_debug(this->name, 0, "%s ", get_ip_from_addrinfo(res, &ip));
+ get_ip_from_addrinfo(res, &ip);
+ gf_msg_debug(this->name, 0, "%s ", ip);
if (ip) {
- found = gf_is_loopback_localhost(res->ai_addr, hostname) ||
- gf_interface_search(ip);
+ found = (gf_is_loopback_localhost(res->ai_addr, hostname) ||
+ gf_interface_search(ip));
}
if (found) {
GF_FREE(ip);
goto out;
}
GF_FREE(ip);
+ /* the above free will not set ip to NULL, and hence, there is
+ double free possible as the loop continues. set ip to NULL. */
+ ip = NULL;
}
out:
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index f5cd6a3d88c..1bdd45f9fae 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -286,6 +286,7 @@ rbthash_insert(rbthash_table_t *tbl, void *data, void *key, int keylen)
gf_msg(GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_RBTHASH_INSERT_FAILED,
"Failed to insert entry");
rbthash_deinit_entry(tbl, entry);
+ goto err;
}
LOCK(&tbl->tablelock);