Bug 1361205 - nvdimm: fix memory leak in error code path
Summary: nvdimm: fix memory leak in error code path
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Stefan Hajnoczi
QA Contact: Yumei Huang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-28 13:43 UTC by Stefan Hajnoczi
Modified: 2016-11-07 21:27 UTC (History)
6 users (show)

Fixed In Version: qemu-kvm-rhev-2.6.0-18.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-07 21:27:03 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2673 normal SHIPPED_LIVE qemu-kvm-rhev bug fix and enhancement update 2016-11-08 01:06:13 UTC

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@redhat.com>
  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


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