From 95f59725adbefd574cfd694dc101ee9c803f167a Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Tue, 22 Mar 2011 04:50:07 +0000 Subject: free priv structure if something fails in init for locks Signed-off-by: Raghavendra Bhat Signed-off-by: Vijay Bellur BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346 --- xlators/features/locks/src/posix.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'xlators/features/locks') diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 7b72e9ee707..67f026b1627 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -1799,11 +1799,12 @@ init (xlator_t *this) xlator_list_t *trav = NULL; data_t *mandatory = NULL; data_t *trace = NULL; + int ret = -1; if (!this->children || this->children->next) { gf_log (this->name, GF_LOG_CRITICAL, "FATAL: posix-locks should have exactly one child"); - return -1; + goto out; } if (!this->parents) { @@ -1819,7 +1820,7 @@ init (xlator_t *this) gf_log (this->name, GF_LOG_CRITICAL, "'locks' translator is not loaded over a storage " "translator"); - return -1; + goto out;; } priv = GF_CALLOC (1, sizeof (*priv), @@ -1836,12 +1837,19 @@ init (xlator_t *this) &priv->trace) == -1) { gf_log (this->name, GF_LOG_ERROR, "'trace' takes on only boolean values."); - return -1; + goto out; } } this->private = priv; - return 0; + ret = 0; + +out: + if (ret) { + if (priv) + GF_FREE (priv); + } + return ret; } -- cgit