Skip to contentSkip to conversation

block: Avoid memleak on qcow2 image info failure

PATCH Applied Eric Blake 4 participants 4 messages Mar 20, 2020 – Mar 23, 2020 Block layer

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 block: Avoid memleak on qcow2 image info failure

If we fail to get bitmap info, we must not leak the encryption info.

Fixes b8968c875f403
Fixes Coverity CID 1421894
---
 block/qcow2.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2.c +1 -0
index d44b45633dbb..e08917ed8462 100644
@@ -4811,6 +4811,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
         if (local_err) {
             error_propagate(errp, local_err);
             qapi_free_ImageInfoSpecific(spec_info);
+            qapi_free_QCryptoBlockInfo(encrypt_info);
             return NULL;
         }
         *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Eric Blake

If we fail to get bitmap info, we must not leak the encryption info.

Fixes b8968c875f403
Fixes Coverity CID 1421894
---
  block/qcow2.c | 1 +
  1 file changed, 1 insertion(+)
block/qcow2.c +0 -0
index d44b45633dbb..e08917ed8462 100644

block/qcow2.c static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs, · line 4817

Quoted 7 lines
block/qcow2.c +1 -0
@@ -4811,6 +4811,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
          if (local_err) {
              error_propagate(errp, local_err);
              qapi_free_ImageInfoSpecific(spec_info);
+            qapi_free_QCryptoBlockInfo(encrypt_info);
              return NULL;
          }
          *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){
Signature · 2 lines
Best regards,
Vladimir
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Eric Blake

________________________________
From: Eric Blake <[email protected]>
Sent: Friday, March 20, 2020 9:36 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Andrey Shinkevich <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; open list:qcow2 <[email protected]>
Subject: [PATCH] block: Avoid memleak on qcow2 image info failure

If we fail to get bitmap info, we must not leak the encryption info.

Fixes b8968c875f403
Fixes Coverity CID 1421894

---

Thank you Eric.
I have made a smoke test only without the crypto object instantiation.

Andrey