[PULL 13/19] blockdev: Fix a memleak in drive_backup_prepare()

Laurent Vivier posted 19 patches 4 years, 11 months ago
Maintainers: Markus Armbruster <armbru@redhat.com>, Anthony Perard <anthony.perard@citrix.com>, Viktor Prutyanov <viktor.prutyanov@phystech.edu>, Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Paul Durrant <paul@xen.org>, Stefano Stabellini <sstabellini@kernel.org>
There is a newer version of this series
[PULL 13/19] blockdev: Fix a memleak in drive_backup_prepare()
Posted by Laurent Vivier 4 years, 11 months ago
From: Pan Nengyuan <pannengyuan@huawei.com>

'local_err' seems forgot to propagate in error path, it'll cause
a memleak. Fix it.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
Message-Id: <20201023061218.2080844-7-kuhn.chenqun@huawei.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 blockdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/blockdev.c b/blockdev.c
index 412354b4b6ac..2431448c5d41 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1827,6 +1827,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
     if (set_backing_hd) {
         bdrv_set_backing_hd(target_bs, source, &local_err);
         if (local_err) {
+            error_propagate(errp, local_err);
             goto unref;
         }
     }
-- 
2.29.2