Patchwork block: bdrv_create(): don't leak cco.filename on error

login
register
mail settings
Submitter Luiz Capitulino
Date Oct. 17, 2012, 7:45 p.m.
Message ID <20121017164525.0e9b2941@doriath.home>
Download mbox | patch
Permalink /patch/192129/
State New
Headers show

Comments

Luiz Capitulino - Oct. 17, 2012, 7:45 p.m.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Stefan Hajnoczi - Oct. 18, 2012, 7:15 a.m.
On Wed, Oct 17, 2012 at 04:45:25PM -0300, Luiz Capitulino wrote:
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  block.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Kevin Wolf - Oct. 18, 2012, 9:46 a.m.
Am 17.10.2012 21:45, schrieb Luiz Capitulino:
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block.c b/block.c
index 5e8184f..63bf768 100644
--- a/block.c
+++ b/block.c
@@ -379,7 +379,8 @@  int bdrv_create(BlockDriver *drv, const char* filename,
     };
 
     if (!drv->bdrv_create) {
-        return -ENOTSUP;
+        ret = -ENOTSUP;
+        goto out;
     }
 
     if (qemu_in_coroutine()) {
@@ -394,8 +395,9 @@  int bdrv_create(BlockDriver *drv, const char* filename,
     }
 
     ret = cco.ret;
-    g_free(cco.filename);
 
+out:
+    g_free(cco.filename);
     return ret;
 }