Bug 396461 - Memory leak in alloc_disk()
Memory leak in alloc_disk()
Status: CLOSED DUPLICATE of bug 435892
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Jerome Marchand
Martin Jenner
Depends On: 395571
  Show dependency treegraph
Reported: 2007-11-23 05:40 EST by Jerome Marchand
Modified: 2008-03-04 06:15 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:15:14 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 (383 bytes, patch)
2007-11-23 05:40 EST, Jerome Marchand
no flags Details | Diff

  None (edit)
Description Jerome Marchand 2007-11-23 05:40:24 EST
+++ This bug was initially created as a clone of Bug #395571 +++

Description of problem:
A memory leak may occur in alloc_disk().

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

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:

-- Additional comment from jmarchan@redhat.com on 2007-11-22 06:57 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.

-- Additional comment from jmarchan@redhat.com on 2007-11-22 06:59 EST --
Created an attachment (id=266761)
proposed patch

-- Additional comment from jmarchan@redhat.com on 2007-11-22 07:00 EST --
Upstream is also affected
Comment 1 Jerome Marchand 2007-11-23 05:40:24 EST
Created attachment 267471 [details]
proposed patch
Comment 2 Prarit Bhargava 2007-11-26 13:36:27 EST
Jerome -- did this ever make it upstream?

Also, should this be assigned to you?

Comment 3 Jerome Marchand 2007-11-27 04:15:55 EST
It's in -mm tree now:

Yes, you can assign this to me.
Comment 4 RHEL Product and Program Management 2008-02-14 16:39:43 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 5 Jan Lieskovsky 2008-03-04 06:15:14 EST

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

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