summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2017-01-13 12:17:05 +0530
committerNiels de Vos <ndevos@redhat.com>2017-01-16 01:32:13 -0800
commitafdd83a9b69573b854e732795c0bcba0a00d6c0f (patch)
treed3fff9461fa8e62dc72a037ef737f008c9e6b413 /xlators/features
parent2041fb7872fa6672e9164fd2a12aaf80e6ef3ebd (diff)
upcall: Resolve dict leak from up_(f)removexattr in upcall code path
Problem: In up_(f)removexattr() dict_for_key_value() is used to create a new dict. This dict is not correctly unref'd and gets leaked. Solution: To avoid the leak up_(f)removexattr() now also does a dict_unref() on the newly created dict. While reviewing the code in up_(f)setxattr() for a similar problem, it was noticed that there is an extra dict created. There is no need for this copy, upcall_local_init() can just take the dict that was passed as argument to the FOP. BUG: 1412917 Change-Id: I5bb9a7d99f5087af11c19ae722de62bdb5ad1498 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com> Reviewed-on: http://review.gluster.org/16392 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/upcall/src/upcall.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index 153e3a8e59f..19180e555f5 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -1682,22 +1682,14 @@ up_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
- dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- xattr = dict_copy_with_ref (dict, NULL);
- if (!xattr) {
- op_errno = ENOMEM;
- goto err;
- }
-
- local = upcall_local_init (frame, this, loc, NULL, loc->inode, xattr);
+ local = upcall_local_init (frame, this, loc, NULL, loc->inode, dict);
if (!local) {
op_errno = ENOMEM;
goto err;
}
- dict_unref (xattr);
out:
STACK_WIND (frame, up_setxattr_cbk, FIRST_CHILD(this),
@@ -1707,8 +1699,6 @@ out:
return 0;
err:
- if (xattr)
- dict_unref (xattr);
UPCALL_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL);
return 0;
@@ -1769,22 +1759,14 @@ up_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
{
int32_t op_errno = -1;
upcall_local_t *local = NULL;
- dict_t *xattr = NULL;
EXIT_IF_UPCALL_OFF (this, out);
- xattr = dict_copy_with_ref (dict, NULL);
- if (!xattr) {
- op_errno = ENOMEM;
- goto err;
- }
-
- local = upcall_local_init (frame, this, NULL, fd, fd->inode, xattr);
+ local = upcall_local_init (frame, this, NULL, fd, fd->inode, dict);
if (!local) {
op_errno = ENOMEM;
goto err;
}
- dict_unref (xattr);
out:
STACK_WIND (frame, up_fsetxattr_cbk,
@@ -1794,8 +1776,6 @@ out:
return 0;
err:
- if (xattr)
- dict_unref (xattr);
UPCALL_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL);
return 0;
@@ -1872,12 +1852,18 @@ up_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
out:
+ if (xattr)
+ dict_unref (xattr);
+
STACK_WIND (frame, up_fremovexattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->fremovexattr,
fd, name, xdata);
return 0;
err:
+ if (xattr)
+ dict_unref (xattr);
+
UPCALL_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL);
return 0;
@@ -1954,12 +1940,18 @@ up_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
out:
+ if (xattr)
+ dict_unref (xattr);
+
STACK_WIND (frame, up_removexattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr,
loc, name, xdata);
return 0;
err:
+ if (xattr)
+ dict_unref (xattr);
+
UPCALL_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL);
return 0;