[libvirt] [PATCH] conf: Fix resource leak in virCapabilitiesInitCaches

Martin Kletzander mkletzan at redhat.com
Fri May 12 11:38:39 UTC 2017


On Fri, May 12, 2017 at 06:48:51AM -0400, John Ferlan wrote:
>The @type from virFileReadValueString needs to be VIR_FREE each time
>through the loop since it's not saved and since cleanup can be reached
>prior to decoding it for @kernel_type amd bank->type, the cleanup code
>needs to also have a VIR_FREE
>
>Found by Coverity
>

ACK

>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/conf/capabilities.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
>index c36ca40..d699b08 100644
>--- a/src/conf/capabilities.c
>+++ b/src/conf/capabilities.c
>@@ -1611,10 +1611,10 @@ virCapabilitiesInitCaches(virCapsPtr caps)
>             if (kernel_type < 0) {
>                 virReportError(VIR_ERR_INTERNAL_ERROR,
>                                _("Unknown cache type '%s'"), type);
>-                VIR_FREE(type);
>                 goto cleanup;
>             }
>             bank->type = kernel_type;
>+            VIR_FREE(type);
>
>             for (i = 0; i < caps->host.ncaches; i++) {
>                 if (virCapsHostCacheBankEquals(bank, caps->host.caches[i]))
>@@ -1637,6 +1637,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
>
>     ret = 0;
>  cleanup:
>+    VIR_FREE(type);
>     VIR_FREE(path);
>     virDirClose(&dirp);
>     virCapsHostCacheBankFree(bank);
>--
>2.9.3
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170512/99d3eaeb/attachment-0001.sig>


More information about the libvir-list mailing list