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

[libvirt] [PATCH v2 3/8] Validate address in virDomainPCIAddressReleaseAddr



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 linux vnet ibm com>
---
 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


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