[PATCH v2 3/8] Validate address in virDomainPCIAddressReleaseAddr

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

 



This function was not used so far. Now, that we begin to use it, make sure to
check the address before actually releasing the address.

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_addr.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 35c7cd4..7ea9e4d 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -497,8 +497,24 @@ int
 virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
                                virPCIDeviceAddressPtr addr)
 {
+    /* permit any kind of connection type in validation, since we
+     * already had it, and are giving it back.
+     */
+    virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPES_MASK;
+    int ret = -1;
+    char *addrStr = NULL;
+
+    if (!(addrStr = virDomainPCIAddressAsString(addr)))
+        goto cleanup;
+
+    if (!virDomainPCIAddressValidate(addrs, addr, addrStr, flags, false))
+        goto cleanup;
+
     addrs->buses[addr->bus].slots[addr->slot] &= ~(1 << addr->function);
-    return 0;
+    ret = 0;
+ cleanup:
+    VIR_FREE(addrStr);
+    return ret;
 }
 
 int

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