[libvirt] [PATCH] conf: fix memory leak in virNodeDevPCICapSRIOVVirtualParseXML
Daniel Henrique Barboza
danielhb413 at gmail.com
Thu Sep 19 13:35:26 UTC 2019
On 9/19/19 5:01 AM, Xu Yandong wrote:
> In function virNodeDevPCICapSRIOVVirtualParseXML, temp variable
> addr could leak if VIR_APPEND_ELEMENT fails .
>
> Signed-off-by: Xu Yandong <xuyandong2 at huawei.com>
> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> src/conf/node_device_conf.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> 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;
More information about the libvir-list
mailing list