Re: [PATCH] conf: fix memory leak in virNodeDevPCICapSRIOVVirtualParseXML

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

 



On Thu, Sep 19, 2019 at 04:01:31AM -0400, Xu Yandong wrote:
In function virNodeDevPCICapSRIOVVirtualParseXML, temp variable
addr could leak if VIR_APPEND_ELEMENT fails .

Signed-off-by: Xu Yandong <xuyandong2@xxxxxxxxxx>
---
src/conf/node_device_conf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)


A nicer fix would be to remove the remaining VIR_FREE(addr) and mark the
declaration with VIR_AUTOFREE

Jano

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 618ce8e00e..2d8e03e53e 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1519,8 +1519,10 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,

        if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
                               pci_dev->num_virtual_functions,
-                               addr) < 0)
+                               addr) < 0) {
+            VIR_FREE(addr);
            goto cleanup;
+        }
    }

    pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
--
2.18.1

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

Attachment: signature.asc
Description: PGP 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]

  Powered by Linux