Blame SOURCES/kvm-block-Fix-leak-in-bdrv_create_file_fallback.patch

22c213
From 05452efd7e0fb0522099ae09a396f8f97e66014a Mon Sep 17 00:00:00 2001
22c213
From: Maxim Levitsky <mlevitsk@redhat.com>
22c213
Date: Wed, 11 Mar 2020 10:51:47 +0000
22c213
Subject: [PATCH 06/20] block: Fix leak in bdrv_create_file_fallback()
22c213
22c213
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
22c213
Message-id: <20200311105147.13208-7-mlevitsk@redhat.com>
22c213
Patchwork-id: 94229
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 6/6] block: Fix leak in bdrv_create_file_fallback()
22c213
Bugzilla: 1640894
22c213
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
22c213
RH-Acked-by: John Snow <jsnow@redhat.com>
22c213
RH-Acked-by: Max Reitz <mreitz@redhat.com>
22c213
22c213
From: Max Reitz <mreitz@redhat.com>
22c213
22c213
@options is leaked by the first two return statements in this function.
22c213
22c213
Note that blk_new_open() takes the reference to @options even on
22c213
failure, so all we need to do to fix the leak is to move the QDict
22c213
allocation down to where we actually need it.
22c213
22c213
Reported-by: Coverity (CID 1419884)
22c213
Fixes: fd17146cd93d1704cd96d7c2757b325fc7aac6fd
22c213
       ("block: Generic file creation fallback")
22c213
Signed-off-by: Max Reitz <mreitz@redhat.com>
22c213
Message-Id: <20200225155618.133412-1-mreitz@redhat.com>
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
(cherry picked from commit eeea1faa099f82328f5831cf252f8ce0a59a9287)
22c213
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
22c213
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 block.c | 3 ++-
22c213
 1 file changed, 2 insertions(+), 1 deletion(-)
22c213
22c213
diff --git a/block.c b/block.c
22c213
index 3beec7f..e1a4e38 100644
22c213
--- a/block.c
22c213
+++ b/block.c
22c213
@@ -600,7 +600,7 @@ static int bdrv_create_file_fallback(const char *filename, BlockDriver *drv,
22c213
                                      QemuOpts *opts, Error **errp)
22c213
 {
22c213
     BlockBackend *blk;
22c213
-    QDict *options = qdict_new();
22c213
+    QDict *options;
22c213
     int64_t size = 0;
22c213
     char *buf = NULL;
22c213
     PreallocMode prealloc;
22c213
@@ -623,6 +623,7 @@ static int bdrv_create_file_fallback(const char *filename, BlockDriver *drv,
22c213
         return -ENOTSUP;
22c213
     }
22c213
 
22c213
+    options = qdict_new();
22c213
     qdict_put_str(options, "driver", drv->format_name);
22c213
 
22c213
     blk = blk_new_open(filename, NULL, options,
22c213
-- 
22c213
1.8.3.1
22c213