[Qemu-devel] [PATCH] nbd: fix memory leak on socket_connect failed

yaolujing posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1491005709-29989-1-git-send-email-yaolujing@huawei.com
Test checkpatch passed
Test docker passed
Test s390x passed
block/nbd.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] nbd: fix memory leak on socket_connect failed
Posted by yaolujing 7 years ago
From: y00357587 <yaolujing@huawei.com>

When TCP connection fails between nbd server and client,
the local var, sioc, memory leak.

This patch fixes the memory leak.

Signed-off-by: y00357587 <yaolujing@huawei.com>
---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/nbd.c b/block/nbd.c
index 35f24be..102285e 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -313,6 +313,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
                                     saddr,
                                     &local_err);
     if (local_err) {
+        object_unref(OBJECT(sioc));
         error_propagate(errp, local_err);
         return NULL;
     }
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH for-2.9] nbd: fix memory leak on socket_connect failed
Posted by Eric Blake 7 years ago
On 03/31/2017 07:15 PM, yaolujing wrote:
> From: y00357587 <yaolujing@huawei.com>
> 
> When TCP connection fails between nbd server and client,
> the local var, sioc, memory leak.
> 
> This patch fixes the memory leak.
> 
> Signed-off-by: y00357587 <yaolujing@huawei.com>
> ---
>  block/nbd.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/nbd.c b/block/nbd.c
> index 35f24be..102285e 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -313,6 +313,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
>                                      saddr,
>                                      &local_err);
>      if (local_err) {
> +        object_unref(OBJECT(sioc));
>          error_propagate(errp, local_err);
>          return NULL;
>      }
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Re: [Qemu-devel] [PATCH] nbd: fix memory leak on socket_connect failed
Posted by Paolo Bonzini 7 years ago

On 01/04/2017 02:15, yaolujing wrote:
> From: y00357587 <yaolujing@huawei.com>
> 
> When TCP connection fails between nbd server and client,
> the local var, sioc, memory leak.
> 
> This patch fixes the memory leak.
> 
> Signed-off-by: y00357587 <yaolujing@huawei.com>
> ---
>  block/nbd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index 35f24be..102285e 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -313,6 +313,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
>                                      saddr,
>                                      &local_err);
>      if (local_err) {
> +        object_unref(OBJECT(sioc));
>          error_propagate(errp, local_err);
>          return NULL;
>      }
> 

Queued, thanks.

Paolo