]> 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)
committerLaine Stump <laine@laine.org>
Mon, 1 Jul 2013 04:26:33 +0000 (00:26 -0400)
commit2c2525ab6a6f0ad5d75a6c60711e2e28cb1cebe9
tree77ef4a1050c4b419e46ad2ba8a4e472fe9d9baed
parent374c5e4f73577b316fed19bbcefe74b75195eb95
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.
src/util/virnetdev.c
src/util/virpci.c