[PATCH] src: fix resource leak introduced in d4439a6b8

Nikolay Shirokovskiy posted 1 patch 2 weeks, 4 days ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1610027614-715743-1-git-send-email-nshirokovskiy@virtuozzo.com
src/libvirt-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH] src: fix resource leak introduced in d4439a6b8

Posted by Nikolay Shirokovskiy 2 weeks, 4 days ago
@tmp that was copied just above is leaked on plain return.
The issue is found by Coverity.

Patch that inroduced a leak:
d4439a6b8 : src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
---
 src/libvirt-domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 2f9081a..c9f8ffd 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3022,7 +3022,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
     ret = VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
                                    VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION);
     if (ret < 0)
-        return NULL;
+        goto done;
     if (ret)
         protection = VIR_MIGRATE_CHANGE_PROTECTION;
 
-- 
1.8.3.1

Re: [PATCH] src: fix resource leak introduced in d4439a6b8

Posted by Daniel P. Berrangé 2 weeks, 4 days ago
On Thu, Jan 07, 2021 at 04:53:34PM +0300, Nikolay Shirokovskiy wrote:
> @tmp that was copied just above is leaked on plain return.
> The issue is found by Coverity.
> 
> Patch that inroduced a leak:
> d4439a6b8 : src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
> ---
>  src/libvirt-domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 2f9081a..c9f8ffd 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -3022,7 +3022,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
>      ret = VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
>                                     VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION);
>      if (ret < 0)
> -        return NULL;
> +        goto done;
>      if (ret)
>          protection = VIR_MIGRATE_CHANGE_PROTECTION;

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|