From 7d0a305e23a28631c7c3e8cfc648c9c9a24148f6 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Mon, 8 Sep 2014 21:52:30 +0530 Subject: quota/marker: Fix dict leaks Unref dicts in quota and marker functions before they return. Change-Id: I772edc7b46657a70fb136e037576c65e9beeaca8 BUG: 1139327 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/8655 Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- xlators/features/marker/src/marker.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'xlators/features/marker/src/marker.c') diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 465ee8c7ce6..b037844e855 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -250,7 +250,8 @@ marker_getxattr_stampfile_cbk (call_frame_t *frame, xlator_t *this, STACK_UNWIND_STRICT (getxattr, frame, 0, 0, dict, xdata); - dict_unref (dict); + if (dict) + dict_unref (dict); out: return 0; } @@ -2778,7 +2779,11 @@ marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, priv = this->private; - if ((dict != NULL) && dict_get (dict, GET_ANCESTRY_DENTRY_KEY)) { + dict = dict ? dict_ref(dict) : dict_new(); + if (!dict) + goto unwind; + + if (dict_get (dict, GET_ANCESTRY_DENTRY_KEY)) { STACK_WIND (frame, marker_build_ancestry_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, @@ -2791,9 +2796,6 @@ marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, loc.parent = local->loc.inode = inode_ref (fd->inode); - if (dict == NULL) - dict = dict_new (); - mq_req_xattr (this, &loc, dict); } @@ -2803,10 +2805,13 @@ marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, fd, size, offset, dict); } + dict_unref (dict); + return 0; +unwind: + STACK_UNWIND_STRICT (readdirp, frame, -1, ENOMEM, NULL, NULL); return 0; } - int32_t mem_acct_init (xlator_t *this) { -- cgit