From fcb5ebde1e84da871a7f43df9ecbce7d1d1de435 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Thu, 8 Mar 2012 16:11:58 -0500 Subject: system/posix-acl: fix reference counting in posix_acl_readdirp_cbk unref. the acl pointers from posix_acl_get() Change-Id: I1247f64ceded17bfa204d1b899ec56a27bef0cdb Signed-off-by: Brian Foster BUG: 801183 Reviewed-on: http://review.gluster.com/2904 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Amar Tumballi --- xlators/system/posix-acl/src/posix-acl.c | 33 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c index 0e92cb35f31..0fe47c71d79 100644 --- a/xlators/system/posix-acl/src/posix-acl.c +++ b/xlators/system/posix-acl/src/posix-acl.c @@ -1450,12 +1450,14 @@ posix_acl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (acl_access && posix_acl_matches_xattr (this, acl_access, data->data, - data->len)) { - acl_access = posix_acl_ref (this, acl_access); - } else { - acl_access = posix_acl_from_xattr (this, data->data, - data->len); - } + data->len)) + goto acl_default; + + if (acl_access) + posix_acl_unref(this, acl_access); + + acl_access = posix_acl_from_xattr (this, data->data, + data->len); acl_default: data = dict_get (entry->dict, POSIX_ACL_DEFAULT_XATTR); @@ -1464,12 +1466,14 @@ posix_acl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (acl_default && posix_acl_matches_xattr (this, acl_default, data->data, - data->len)) { - acl_default = posix_acl_ref (this, acl_default); - } else { - acl_default = posix_acl_from_xattr (this, data->data, - data->len); - } + data->len)) + goto acl_set; + + if (acl_default) + posix_acl_unref(this, acl_default); + + acl_default = posix_acl_from_xattr (this, data->data, + data->len); acl_set: posix_acl_ctx_update (entry->inode, this, &entry->d_stat); @@ -1479,6 +1483,11 @@ posix_acl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (ret) gf_log (this->name, GF_LOG_WARNING, "failed to set ACL in context"); + + if (acl_access) + posix_acl_unref(this, acl_access); + if (acl_default) + posix_acl_unref(this, acl_default); } unwind: -- cgit