Bug 395571 - Memory leak in alloc_disk_node()
Memory leak in alloc_disk_node()
Status: CLOSED DUPLICATE of bug 395861
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Jerome Marchand
Martin Jenner
Depends On:
Blocks: 396461
  Show dependency treegraph
Reported: 2007-11-22 06:52 EST by Jerome Marchand
Modified: 2008-03-04 06:22 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-03-04 06:22:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
proposed patch (359 bytes, text/x-patch)
2007-11-22 06:59 EST, Jerome Marchand
no flags Details
RHEL5 patch (423 bytes, patch)
2007-12-18 04:04 EST, Jerome Marchand
no flags Details | Diff

  None (edit)
Description Jerome Marchand 2007-11-22 06:52:53 EST
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:
Actual results:

Expected results:

Additional info:
Comment 1 Jerome Marchand 2007-11-22 06:57:34 EST
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)) {
			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 06:59:22 EST
Created attachment 266761 [details]
proposed patch
Comment 3 Jerome Marchand 2007-11-22 07:00:50 EST
Upstream is also affected
Comment 4 Jerome Marchand 2007-11-23 05:43:41 EST
The patch was accepted upstream:
Comment 5 RHEL Product and Program Management 2007-12-17 17:06:06 EST
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
Comment 6 Jerome Marchand 2007-12-18 04:04:53 EST
Created attachment 289866 [details]
RHEL5 patch
Comment 7 Jan Lieskovsky 2008-03-04 06:22:38 EST

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

Note You need to log in before you can comment on or make changes to this bug.