Re: [PATCH] virpci: Resolve coverity issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
> 
> 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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]