Skip to contentSkip to conversation

bochs: Fix memory leak in bochs_open() error path

PATCH In review Kevin Wolf 2 participants 2 messages Apr 9, 2014 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 bochs: Fix memory leak in bochs_open() error path

---
 block/bochs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
block/bochs.c +4 -2
index 826ec12..50b84a9 100644
@@ -150,11 +150,13 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
     s->extent_size = le32_to_cpu(bochs.extent);
     if (s->extent_size == 0) {
         error_setg(errp, "Extent size may not be zero");
-        return -EINVAL;
+        ret = -EINVAL;
+        goto fail;
     } else if (s->extent_size > 0x800000) {
         error_setg(errp, "Extent size %" PRIu32 " is too large",
                    s->extent_size);
-        return -EINVAL;
+        ret = -EINVAL;
+        goto fail;
     }
 
     if (s->catalog_size < bs->total_sectors / s->extent_size) {
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Kevin Wolf
---
 block/bochs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
block/bochs.c +1 -1
index 826ec12..50b84a9 100644
@@ -150,11 +150,13 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
     s->extent_size = le32_to_cpu(bochs.extent);
     if (s->extent_size == 0) {
         error_setg(errp, "Extent size may not be zero");
-        return -EINVAL;
+        ret = -EINVAL;

block/bochs.c static int bochs_open(BlockDriverState *bs, QDict *options, int flags, · line 162

Quoted 10 lines
block/bochs.c +3 -1
+        goto fail;
     } else if (s->extent_size > 0x800000) {
         error_setg(errp, "Extent size %" PRIu32 " is too large",
                    s->extent_size);
-        return -EINVAL;
+        ret = -EINVAL;
+        goto fail;
     }
 
     if (s->catalog_size < bs->total_sectors / s->extent_size) {