diff mbox series

[v2,1/2] crypto: luks: fix tiny memory leak

Message ID 20201011102136.622361-2-mlevitsk@redhat.com
State New
Headers show
Series qcow2: don't leave partially initialized file on image creation | expand

Commit Message

Maxim Levitsky Oct. 11, 2020, 10:21 a.m. UTC
In the case when underlying block device doesn't support the
bdrv_co_delete_file interface, an 'Error' wasn't freed.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/crypto.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Alberto Garcia Oct. 13, 2020, 12:26 p.m. UTC | #1
On Sun 11 Oct 2020 12:21:35 PM CEST, Maxim Levitsky wrote:
> In the case when underlying block device doesn't support the
> bdrv_co_delete_file interface, an 'Error' wasn't freed.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  block/crypto.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/block/crypto.c b/block/crypto.c
> index 0807557763..9b61fd4aa8 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -736,6 +736,7 @@ fail:
>          if ((r_del < 0) && (r_del != -ENOTSUP)) {
>              error_report_err(local_delete_err);
>          }
> +        error_free(local_delete_err);
>      }

error_report_err() already calls error_free().

Berto
Maxim Levitsky Oct. 13, 2020, 12:31 p.m. UTC | #2
On Tue, 2020-10-13 at 14:26 +0200, Alberto Garcia wrote:
> On Sun 11 Oct 2020 12:21:35 PM CEST, Maxim Levitsky wrote:
> > In the case when underlying block device doesn't support the
> > bdrv_co_delete_file interface, an 'Error' wasn't freed.
> > 
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > ---
> >  block/crypto.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/block/crypto.c b/block/crypto.c
> > index 0807557763..9b61fd4aa8 100644
> > --- a/block/crypto.c
> > +++ b/block/crypto.c
> > @@ -736,6 +736,7 @@ fail:
> >          if ((r_del < 0) && (r_del != -ENOTSUP)) {
> >              error_report_err(local_delete_err);
> >          }
> > +        error_free(local_delete_err);
> >      }
> 
> error_report_err() already calls error_free().

Thanks. I didn't knew this.
Will send V3 soon.

Best regards,
	Maxim Levitsky
> 
> Berto
>
diff mbox series

Patch

diff --git a/block/crypto.c b/block/crypto.c
index 0807557763..9b61fd4aa8 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -736,6 +736,7 @@  fail:
         if ((r_del < 0) && (r_del != -ENOTSUP)) {
             error_report_err(local_delete_err);
         }
+        error_free(local_delete_err);
     }
 
     bdrv_unref(bs);