From a66a483be2febd36e6cb338c9fe73d332257d89e Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 11 Aug 2014 20:22:53 +0530 Subject: cluster/afr: Fix mem-leak Problem: local->xattr_req is already reffed with xattr_req that comes in lookup fop. But when afr_lookup_xattr_req_prepare is called local->xattr_req is over-written with dict_new() which leads to ref leak on the dict which came in lookup fop Fix: Create local->xattr_req only when it is NULL Change-Id: Ib1548f2df97688859f2cace44b93b3b733297c36 BUG: 1128801 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/8457 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/cluster/afr/src/afr-common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xlators/cluster/afr') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 04191649b4c..8fc202512f1 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -679,10 +679,13 @@ afr_lookup_xattr_req_prepare (afr_local_t *local, xlator_t *this, { int ret = -ENOMEM; - local->xattr_req = dict_new (); + if (!local->xattr_req) + local->xattr_req = dict_new (); + if (!local->xattr_req) goto out; - if (xattr_req) + + if (xattr_req != local->xattr_req) dict_copy (xattr_req, local->xattr_req); ret = afr_xattr_req_prepare (this, local->xattr_req); -- cgit