Skip to contentSkip to conversation

nbd: fix memory leak on socket_connect failed

PATCH Applied yaolujing 3 participants 3 messages Apr 1, 2017 – Apr 3, 2017 Block layer

lore
Share & tools
lore

yaolujing

author
#0 lore raw

PATCH 1/1 nbd: fix memory leak on socket_connect failed

From: y00357587 <[email protected]>

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

This patch fixes the memory leak.

---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
block/nbd.c +1 -0
index 35f24be..102285e 100644
@@ -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;
     }
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · yaolujing

From: y00357587 <[email protected]>

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

This patch fixes the memory leak.

---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines
block/nbd.c +1 -0
index 35f24be..102285e 100644
@@ -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;
     }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to yaolujing
Quoted 18 lines · yaolujing

From: y00357587 <[email protected]>

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

This patch fixes the memory leak.

---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
block/nbd.c +0 -0
index 35f24be..102285e 100644

block/nbd.c static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, · line 319

Quoted 7 lines
block/nbd.c +1 -0
@@ -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