summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorBhumika Goyal <bgoyal@redhat.com>2018-12-06 15:04:55 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2018-12-11 14:28:04 +0000
commite41fee7ba316655cdaafb9234a1590051f82db11 (patch)
tree605a300c0a2fd5e69dca2b1aa7bb0234f2649f17 /xlators/cluster
parent08adbfb5d2edf9dc01ecc2cf2ca5eccb320b8721 (diff)
afr: Resource leak coverity fixes
Problem reported by Coverity: Leak of memory or pointers to system resources. Deallocate the memory pointed to by xattr_serz as the memory reference is not stored anywhere. Fixes CID: 1124760, 124787, 1382418 Change-Id: Ib9c2ef28c52e2d43de2552cfd959a98b26272bc1 updates: bz#789278 Signed-off-by: Bhumika Goyal <bgoyal@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index d31fdaa7542..a4de48eae34 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -802,6 +802,7 @@ unlock:
if (ret) {
local->op_ret = -1;
local->op_errno = ENOMEM;
+ GF_FREE(xattr_serz);
goto unwind;
}
ret = dict_set_dynstr(local->dict, GF_XATTR_LIST_NODE_UUIDS_KEY,
@@ -811,6 +812,8 @@ unlock:
"Cannot set node_uuid key in dict");
local->op_ret = -1;
local->op_errno = ENOMEM;
+ if (ret == -EINVAL)
+ GF_FREE(xattr_serz);
} else {
local->op_ret = local->cont.getxattr.xattr_len - 1;
local->op_errno = 0;
@@ -1178,6 +1181,7 @@ unlock:
ret = dict_serialize_value_with_delim(
local->dict, xattr_serz + xattr_serz_len, &tlen, ' ');
if (ret) {
+ GF_FREE(xattr_serz);
goto unwind;
}
@@ -1186,9 +1190,12 @@ unlock:
*(xattr_serz + padding + tlen + 1) = '\0';
ret = dict_set_dynstr(nxattr, local->cont.getxattr.name, xattr_serz);
- if (ret)
+ if (ret) {
gf_msg(this->name, GF_LOG_ERROR, -ret, AFR_MSG_DICT_SET_FAILED,
"Cannot set pathinfo key in dict");
+ if (ret == -EINVAL)
+ GF_FREE(xattr_serz);
+ }
unwind:
AFR_STACK_UNWIND(fgetxattr, frame, local->op_ret, local->op_errno,
@@ -1295,6 +1302,7 @@ unlock:
ret = dict_serialize_value_with_delim(
local->dict, xattr_serz + xattr_serz_len, &tlen, ' ');
if (ret) {
+ GF_FREE(xattr_serz);
goto unwind;
}
@@ -1303,9 +1311,12 @@ unlock:
*(xattr_serz + padding + tlen + 1) = '\0';
ret = dict_set_dynstr(nxattr, local->cont.getxattr.name, xattr_serz);
- if (ret)
+ if (ret) {
gf_msg(this->name, GF_LOG_ERROR, -ret, AFR_MSG_DICT_SET_FAILED,
"Cannot set pathinfo key in dict");
+ if (ret == -EINVAL)
+ GF_FREE(xattr_serz);
+ }
unwind:
AFR_STACK_UNWIND(getxattr, frame, local->op_ret, local->op_errno,