]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
node_device: fix memory leak in nodeDeviceSysfsGetSCSIHostCaps
authorYi Wang <wang.yi59@zte.com.cn>
Fri, 26 May 2017 02:39:48 +0000 (22:39 -0400)
committerErik Skultety <eskultet@redhat.com>
Fri, 26 May 2017 11:16:36 +0000 (13:16 +0200)
@tmp is leaked after the second call to virVHBAGetConfig within
virVHBAIsVportCapable code block because it wasn't freed after making the
first call to the function.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/node_device/node_device_linux_sysfs.c

index 1b7aa9435c5fe879b777b579503588beee7b3fd0..ecfe34d4197786b769f24051b8f4109796dab0ef 100644 (file)
@@ -95,8 +95,9 @@ nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host)
             goto cleanup;
         }
 
-         if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
-                                      "npiv_vports_inuse"))) {
+        VIR_FREE(tmp);
+        if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
+                                     "npiv_vports_inuse"))) {
             VIR_WARN("Failed to read npiv_vports_inuse for host%d",
                      scsi_host->host);
             goto cleanup;