Skip to contentSkip to conversation

rbd: Fix leaks in rbd_start_aio() error path

PATCH Applied Kevin Wolf 4 participants 4 messages Jun 5, 2014 – Jun 9, 2014 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH v2 1/1 rbd: Fix leaks in rbd_start_aio() error path

---
 block/rbd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
block/rbd.c +4 -1
index 09af484..898fcfe 100644
@@ -684,13 +684,16 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     }
 
     if (r < 0) {
-        goto failed;
+        goto failed_completion;
     }
 
     return &acb->common;
 
+failed_completion:
+    rbd_aio_release(c);
 failed:
     g_free(rcb);
+    qemu_vfree(acb->bounce);
     qemu_aio_release(acb);
     return NULL;
 }
Signature · 1 line
1.8.3.1
Reviewed-by Benoit Canet on v2 1/1
#1 lore raw
Quoted 30 lines · Kevin Wolf
---
 block/rbd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
block/rbd.c +4 -1
index 09af484..898fcfe 100644
@@ -684,13 +684,16 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     }
 
     if (r < 0) {
-        goto failed;
+        goto failed_completion;
     }
 
     return &acb->common;
 
+failed_completion:
+    rbd_aio_release(c);
 failed:
     g_free(rcb);
+    qemu_vfree(acb->bounce);
     qemu_aio_release(acb);
     return NULL;
 }
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 18 lines · Kevin Wolf
---
  block/rbd.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
block/rbd.c +1 -1
index 09af484..898fcfe 100644
@@ -684,13 +684,16 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
      }
 
      if (r < 0) {
-        goto failed;
+        goto failed_completion;
      }
 

block/rbd.c static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs, · line 699

Quoted 10 lines
block/rbd.c +3 -0
      return &acb->common;
 
+failed_completion:
+    rbd_aio_release(c);
  failed:
      g_free(rcb);
+    qemu_vfree(acb->bounce);
      qemu_aio_release(acb);
      return NULL;
  }

FWIW this error path can only happen in certain combinations of odd circumstances, including specific forms of disk corruption of certain objects in concert with other factors, so it's quite unlikely to occur in practice.