Bug 395571

Summary: Memory leak in alloc_disk_node()
Product: Red Hat Enterprise Linux 5 Reporter: Jerome Marchand <jmarchan>
Component: kernelAssignee: Jerome Marchand <jmarchan>
Status: CLOSED DUPLICATE QA Contact: Martin Jenner <mjenner>
Severity: low Docs Contact:
Priority: low    
Version: 5.1CC: dzickus
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-04 11:22:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 396461    
Attachments:
Description Flags
proposed patch
none
RHEL5 patch none

Description Jerome Marchand 2007-11-22 11:52:53 UTC
Description of problem:
A memory leak may occur in alloc_disk_node().

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Jerome Marchand 2007-11-22 11:57:34 UTC
The problem is in alloc_disk_mode() function:

	disk = kmalloc_node(sizeof(struct gendisk),
				GFP_KERNEL | __GFP_ZERO, node_id);
	if (disk) {
		if (!init_disk_stats(disk)) {
			kfree(disk);
			return NULL;
		}
		if (minors > 1) {
			int size = (minors - 1) * sizeof(struct hd_struct *);
			disk->part = kmalloc_node(size,
				GFP_KERNEL | __GFP_ZERO, node_id);
			if (!disk->part) {
				kfree(disk);  >>> here we forget to free disk->dkstats
				return NULL;
			}
		}

If the allocation of disk and disk->dkstats are successful but not the
allocation of disk->part, we forget to free disk->dkstats.

Comment 2 Jerome Marchand 2007-11-22 11:59:22 UTC
Created attachment 266761 [details]
proposed patch

Comment 3 Jerome Marchand 2007-11-22 12:00:50 UTC
Upstream is also affected

Comment 4 Jerome Marchand 2007-11-23 10:43:41 UTC
The patch was accepted upstream:
http://lkml.org/lkml/2007/11/23/20


Comment 5 RHEL Program Management 2007-12-17 22:06:06 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 6 Jerome Marchand 2007-12-18 09:04:53 UTC
Created attachment 289866 [details]
RHEL5 patch

Comment 7 Jan Lieskovsky 2008-03-04 11:22:38 UTC

*** This bug has been marked as a duplicate of 395861 ***