]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tests: fix segfault in objecteventtest
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Wed, 24 Aug 2016 10:37:27 +0000 (13:37 +0300)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 29 Aug 2016 10:51:56 +0000 (13:51 +0300)
commit61148074773ba180f17020b0b11c155b154726fd
tree99e300b199d3cb3c94849d983172cc04f04857fb
parent25ee22bdbc48aa4f25d0e1d80383d73cbe18c2a2
tests: fix segfault in objecteventtest

Test 12 from objecteventtest (createXML add event) segaults on FreeBSD
with bus error.

At some point it calls testNodeDeviceDestroy() from the test driver. And
it fails when it tries to unlock the device in the "out:" label of this
function.

Unlocking fails because the previous step was a call to
virNodeDeviceObjRemove from conf/node_device_conf.c. This function
removes the given device from the device list and cleans up the object,
including destroying of its mutex. However, it does not nullify the pointer
that was given to it.

As a result, we end up in testNodeDeviceDestroy() here:

 out:
    if (obj)
        virNodeDeviceObjUnlock(obj);

And instead of skipping this, we try to do Unlock and fail because of
malformed mutex.

Change virNodeDeviceObjRemove to use double pointer and set pointer to
NULL.
src/conf/node_device_conf.c
src/conf/node_device_conf.h
src/node_device/node_device_hal.c
src/node_device/node_device_udev.c
src/test/test_driver.c