[libvirt] [PATCH] virpci: Resolve coverity issues
Eric Blake
eblake at redhat.com
Fri Feb 7 16:29:04 UTC 2014
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140207/6bdc6c47/attachment-0001.sig>
More information about the libvir-list
mailing list