]> git.ipfire.org Git - thirdparty/libvirt.git/commit
pci: initialize virtual_functions array pointer to avoid segfault
authorLaine Stump <laine@laine.org>
Mon, 1 Jul 2013 03:52:43 +0000 (23:52 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 11 Jul 2013 21:49:19 +0000 (17:49 -0400)
commitb5b269cbc5d1edb34c50a31906dad38cdd2b663f
tree7794d51ddf096a945f44ae069f08a64c7af29868
parenta717d7ba0f93bfc9956fe66cc2cad9f2d0aaa995
pci: initialize virtual_functions array pointer to avoid segfault

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=971325

The problem was that if virPCIGetVirtualFunctions was given the name
of a non-existent interface, it would return to its caller without
initializing the pointer to the array of virtual functions to NULL,
and the caller (virNetDevGetVirtualFunctions) would try to VIR_FREE()
the invalid pointer.

The final error message before the crash would be:

 virPCIGetVirtualFunctions:2088 :
  Failed to open dir '/sys/class/net/eth2/device':
  No such file or directory

In this patch I move the initialization in virPCIGetVirtualFunctions()
to the begining of the function, and also do an explicit
initialization in virNetDevGetVirtualFunctions, just in case someone
in the future adds code into that function prior to the call to
virPCIGetVirtualFunctions.

(cherry picked from commit 2c2525ab6a6f0ad5d75a6c60711e2e28cb1cebe9)
src/util/virnetdev.c
src/util/virpci.c