block/vdi: When writing new bmap entry fails, don't leak the buffer
authorDavid Edmondson <david.edmondson@oracle.com>
Thu, 25 Mar 2021 11:29:36 +0000 (12:29 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 31 Mar 2021 09:44:21 +0000 (10:44 +0100)
If a new bitmap entry is allocated, requiring the entire block to be
written, avoiding leaking the buffer allocated for the block should
the write fail.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Max Reitz <mreitz@redhat.com>
Message-id: 20210325112941.365238-2-pbonzini@redhat.com
Message-Id: <20210309144015.557477-2-david.edmondson@oracle.com>
Acked-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/vdi.c

index 5627e7d764aeeccba87e569f8209caf82dccaa35..2a6dc2612438a34e0a79402747b2b54a71727d95 100644 (file)
@@ -690,6 +690,7 @@ nonallocating_write:
 
     logout("finished data write\n");
     if (ret < 0) {
+        g_free(block);
         return ret;
     }