Bug 395571 - Memory leak in alloc_disk_node()
Summary: Memory leak in alloc_disk_node()
Status: CLOSED DUPLICATE of bug 395861
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel   
(Show other bugs)
Version: 5.1
Hardware: All Linux
Target Milestone: ---
: ---
Assignee: Jerome Marchand
QA Contact: Martin Jenner
Depends On:
Blocks: 396461
TreeView+ depends on / blocked
Reported: 2007-11-22 11:52 UTC by Jerome Marchand
Modified: 2008-03-04 11:22 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-03-04 11:22:38 UTC
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 11:59 UTC, Jerome Marchand
no flags Details
RHEL5 patch (423 bytes, patch)
2007-12-18 09:04 UTC, Jerome Marchand
no flags Details | Diff

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:
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)) {
			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:

Comment 5 RHEL Product and 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

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 ***

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