[PATCH 1/4] util: Fix error path for virPCIGetVirtualFunctions

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

 



If we get to the error: label and clear out the *virtual_functions[]
pointers and then return w/ error to the caller - the caller has it's
own cleanup of the same array in the out: label which is keyed off the
value of num_virt_fns, which wasn't reset to 0 in the called function
leading to a possible problem.

Just clear the value (found by Coverity)

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virpci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 3f1252d..be35017 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2573,6 +2573,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path,
     for (i = 0; i < *num_virtual_functions; i++)
         VIR_FREE((*virtual_functions)[i]);
     VIR_FREE(*virtual_functions);
+    *num_virtual_functions = 0;
     goto cleanup;
 }
 
-- 
2.5.5

--
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]