[libvirt] [PATCH 0/7] Fix resource leaks detected by coverity

Osier Yang jyang at redhat.com
Wed May 2 14:51:31 UTC 2012


RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=771021

For more details, please refer to the coverity logs attached
in the BZ.

There is still one error which I don't understand:

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: alloc_fn: Calling allocation function "virDomainEventNewFromObj".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:723: alloc_fn: Storage is returned from allocation function "virDomainEventNewFromDef".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:728: alloc_fn: Storage is returned from allocation function "virDomainEventNew".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:705: alloc_fn: Storage is returned from allocation function "virDomainEventNewInternal".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:684: alloc_arg: "virAlloc" allocates memory that is stored into "event".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:698: return_alloc: Returning allocated memory "event".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:705: var_assign: Assigning: "event" = "virDomainEventNewInternal(0, id, name, uuid)".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:713: return_alloc: Returning allocated memory "event".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:728: return_alloc_fn: Directly returning storage allocated by "virDomainEventNew".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:723: return_alloc_fn: Directly returning storage allocated by "virDomainEventNewFromDef".
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: var_assign: Assigning: "event" =  storage returned from "virDomainEventNewFromObj(dom, 5, 0)".
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: overwrite_var: Overwriting "event" in call "event = virDomainEventNewFromObj(dom, 5, 0)" leaks the storage that "event" points to.

I can't see how it's overwrote. And I'd persuade myself it's
mistake of coverage. But appreciated if anybody could kill
it if I blindly bypass the porblem.

Osier Yang (7):
  Coverity: Fix the forward_null error in Python binding codes
  Coverity: Fix resource leaks in phyp driver
  Coverity: Fix resource leak in esx driver
  Coverity: Fix resource leak in xen driver
  Coverity: Fix resource leak in test driver
  Coverity: Fix resource leak in nodeinfo.c
  Coverity: Fix resource leak in virnetlink.c

 python/libvirt-override.c |   10 +++++-----
 src/esx/esx_vi.c          |    4 ++++
 src/nodeinfo.c            |    1 +
 src/phyp/phyp_driver.c    |   34 ++++++++++++++++++++--------------
 src/test/test_driver.c    |    1 +
 src/util/virnetlink.c     |    9 +++++----
 src/xen/xen_hypervisor.c  |    5 +++--
 src/xen/xen_inotify.c     |    1 +
 8 files changed, 40 insertions(+), 25 deletions(-)

Regards,
Osier
-- 
1.7.7.3




More information about the libvir-list mailing list