[PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()

Pan Nengyuan posted 12 patches 5 years, 5 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Max Reitz <mreitz@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Pierre Morel <pmorel@linux.ibm.com>, Eduardo Habkost <ehabkost@redhat.com>, Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Thomas Huth <thuth@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Viktor Prutyanov <viktor.prutyanov@phystech.edu>, Markus Armbruster <armbru@redhat.com>, Richard Henderson <rth@twiddle.net>, Alex Williamson <alex.williamson@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Paolo Bonzini <pbonzini@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Juan Quintela <quintela@redhat.com>
There is a newer version of this series
[PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()
Posted by Pan Nengyuan 5 years, 5 months ago
'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>
---
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: qemu-block@nongnu.org
---
 blockdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/blockdev.c b/blockdev.c
index 3848a9c8ab..842ac289c1 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1801,6 +1801,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.18.2


Re: [PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()
Posted by Kevin Wolf 5 years, 5 months ago
Am 14.08.2020 um 18:02 hat Pan Nengyuan geschrieben:
> '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>

I wonder if using ERRP_GUARD() wouldn't simplify this. Anyway, the fix
looks correct:

Reviewed-by: Kevin Wolf <kwolf@redhat.com>


Re: [PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()
Posted by Li Qiang 5 years, 5 months ago
Pan Nengyuan <pannengyuan@huawei.com> 于2020年8月14日周五 下午6:54写道:
>
> '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: Li Qiang <liq3ea@gmail.com>

> ---
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: qemu-block@nongnu.org
> ---
>  blockdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index 3848a9c8ab..842ac289c1 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1801,6 +1801,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.18.2
>
>