Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1361205

Summary: nvdimm: fix memory leak in error code path
Product: Red Hat Enterprise Linux 7 Reporter: Stefan Hajnoczi <stefanha>
Component: qemu-kvm-rhevAssignee: Stefan Hajnoczi <stefanha>
Status: CLOSED ERRATA QA Contact: Yumei Huang <yuhuang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: chayang, juzhang, mrezanin, stefanha, virt-maint, yuhuang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.6.0-18.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-07 21:27:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stefan Hajnoczi 2016-07-28 13:43:17 UTC
The following memory leak was found and fixed upstream:

  commit cdcab9d94101a6dd9ac8136c6f2cd15b6a997896
  Author: Stefan Hajnoczi <stefanha>
  Date:   Tue Jun 28 10:06:46 2016 +0100

  nvdimm: fix memory leak in error code path

  object_get_canonical_path_component() returns a heap-allocated string
  that must be freed using g_free().

This leak is not expected to consume much memory because the nvdimm_realize() error path will not be called often.  It should still be backported to RHEL for correctness.

Comment 1 juzhang 2016-07-29 04:47:03 UTC
Hi Stefan,

Could you provide an efficient way to reproduce and verify this bz?

Best Regards,
Junyi

Comment 2 Stefan Hajnoczi 2016-07-29 15:14:10 UTC
(In reply to juzhang from comment #1)
> Could you provide an efficient way to reproduce and verify this bz?

There is currently no NVDIMM hotplug support so you cannot easily test this at runtime by adding the device many times and watching the RSS memory statistic.

Here is the command-line to trigger the error code path:

  qemu-system-x86_64 -object memory-backend-file,id=memdev0,size=128,mem-path=/tmp/foo -device nvdimm,memdev=memdev0

You could step through nvdimm_realize() under GDB to confirm that path is freed.  If you prefer to just verify that the patch is included in the build then that is fine.

Comment 3 juzhang 2016-08-01 03:37:15 UTC
(In reply to Stefan Hajnoczi from comment #2)
> (In reply to juzhang from comment #1)
> > Could you provide an efficient way to reproduce and verify this bz?
> 
> There is currently no NVDIMM hotplug support so you cannot easily test this
> at runtime by adding the device many times and watching the RSS memory
> statistic.
> 
> Here is the command-line to trigger the error code path:
> 
>   qemu-system-x86_64 -object
> memory-backend-file,id=memdev0,size=128,mem-path=/tmp/foo -device
> nvdimm,memdev=memdev0
> 
> You could step through nvdimm_realize() under GDB to confirm that path is
> freed.  If you prefer to just verify that the patch is included in the build
> then that is fine.

Thanks, Stefan.

Best Regards,
Junyi

Comment 4 Miroslav Rezanina 2016-08-02 15:22:46 UTC
Fix included in qemu-kvm-rhev-2.6.0-18.el7

Comment 8 Stefan Hajnoczi 2016-08-23 21:37:37 UTC
The actual process is executing machine instructions, not lines of C code, so the order of execution might not follow the C source code (due to compiler optimizations).  This means that stepping through a program with gdb can be confusing.

I suggest:
(gdb) b nvdimm_realize
(gdb) r
(gdb) b g_free
(gdb) r

Now you can check that g_free() is being called from line 101 g_free(path) and that path points to a string "memdev0" in memory.

(Maybe g_free() is called from other points in this code path so you may need to continue.)

Comment 10 Yumei Huang 2016-08-24 03:32:43 UTC
Comment 9 is based on qemu-kvm-rhev-2.6.0-21.el7. 

Moving to verified per comment 6 and 9.

Comment 12 errata-xmlrpc 2016-11-07 21:27:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2673.html