Bug 764835 (GLUSTER-3103)

Summary: memleak in inode table creation
Product: [Community] GlusterFS Reporter: Raghavendra Bhat <rabhat>
Component: coreAssignee: Raghavendra Bhat <rabhat>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: mainlineCC: gluster-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: RTNR Mount Type: ---
Documentation: DNR CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Raghavendra Bhat 2011-06-28 13:35:42 UTC
There is memory leak in the creation of inode table creation. If certain allocation such as dentry pool or inode hash fails, then we are simply returning instead of freeing all the previous allocations (such as inode pool).


new->inode_pool = mem_pool_new (inode_t, lru_limit);

        if (!new->inode_pool) {
                GF_FREE (new);
                return NULL;
        }

	new->dentry_pool = mem_pool_new (dentry_t, lru_limit);

        if (!new->dentry_pool) {
		GF_FREE (new);
	        return NULL;
	}

        new->inode_hash = (void *)GF_CALLOC (65536,
                                             sizeof (struct list_head),
                                             gf_common_mt_list_head);
	if (!new->inode_hash) {
                GF_FREE (new);
		return NULL;
	}

Comment 1 Anand Avati 2011-07-01 05:26:20 UTC
PATCH: http://patches.gluster.com/patch/7701 in master (inode table: avoid memleak by freeing the allocated structures incase of failure)

Comment 2 Raghavendra Bhat 2011-07-04 03:31:46 UTC
Its fixed now. The new patch submitted takes care of freeing the allocated pools or structures in case of failure and exiting.

Comment 3 Raghavendra Bhat 2011-07-06 04:27:28 UTC
There is a similar bug in fd_create also where if fd_ctx allocation fails then we are GF_FREEing the fd. But we have to put the fd back to the fd_mem_pool of the inode table.

Comment 4 Anand Avati 2011-07-12 03:19:04 UTC
PATCH: http://patches.gluster.com/patch/7763 in master (fd: put the fd back to fd_mem_pool of inode table instead of freeing in case of failure)