On 02/07/2014 09:21 AM, John Ferlan wrote:
Coverity complains about "USE_AFTER_FREE" due to how
virPCIDeviceSetStubDriver
"could" return either -1, 0, or 1 from the VIR_STRDUP() and then possibly
makes
a call to virPCIDeviceDetach().
The only way this could happen is if NULL were passed as the "driver" name
and virStrdup() returned 0. Since the calling functions check < 0 on the
initial function call, the 0 possibility causes Coverity to complain.
To fix this - enforce that the second parameter is not NULL using
ATTRIBUTE_NONNULL(2) for the function prototype, then in virPCIDeviceDetach
add an sa_assert(dev->stubDriver). This will result in Coverity not complaining
any more.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
NOTE: This replaces Pavel's patch posted yesterday:
http://www.redhat.com/archives/libvir-list/2014-February/msg00319.html
ACK - and now tool-agnostic :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org