From b3c6ee00f9fdc80330979e62fbd7f9bec9440b35 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 12 Sep 2012 14:06:53 +0530 Subject: features/quota: Avoid mem_put on null local Problem: QUOTA_STACK_UNWIND does not check if local is NULL before mem_put. This leads to a callingfn log for every setxattr in quota. Fix: Made sure the mem_put happens only on non-null local in quota. Additional changes: Removed unused QUOTA_STACK_DESTROY macro. Tests: Peformed setfattr on the mount point and the Invalid argument logs don't come anymore. Checked that the change does not introduce any memory leak in quota. Change-Id: Ie4534c7af0fff80e35d8510311055f930262594f BUG: 856541 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/3936 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- xlators/features/quota/src/quota.c | 1 + xlators/features/quota/src/quota.h | 11 ----------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'xlators') diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index cea9a9a0e2b..b60e37d9c80 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -126,6 +126,7 @@ quota_local_cleanup (xlator_t *this, quota_local_t *local) inode_unref (local->inode); LOCK_DESTROY (&local->lock); + mem_put (local); out: return 0; } diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index fe3f46ea010..2b4e9a015ff 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -26,16 +26,6 @@ #define VAL_LENGTH 8 #define READDIR_BUF 4096 -#define QUOTA_STACK_DESTROY(_frame, _this) \ - do { \ - quota_local_t *_local = NULL; \ - _local = _frame->local; \ - _frame->local = NULL; \ - STACK_DESTROY (_frame->root); \ - quota_local_cleanup (_this, _local); \ - GF_FREE (_local); \ - } while (0) - #define QUOTA_SAFE_INCREMENT(lock, var) \ do { \ LOCK (lock); \ @@ -73,7 +63,6 @@ } \ STACK_UNWIND_STRICT (fop, frame, params); \ quota_local_cleanup (_this, _local); \ - mem_put (_local); \ } while (0) #define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \ -- cgit