diff mbox series

[05/12] target/i386/sev: Plug memleak in sev_read_file_base64

Message ID 20200814160241.7915-6-pannengyuan@huawei.com (mailing list archive)
State New, archived
Headers show
Series fix some error memleaks | expand

Commit Message

Pan Nengyuan Aug. 14, 2020, 4:02 p.m. UTC
Missing g_error_free() in sev_read_file_base64() error path.
Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/sev.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Li Qiang Aug. 26, 2020, 10:53 a.m. UTC | #1
Pan Nengyuan <pannengyuan@huawei.com> 于2020年8月14日周五 下午6:37写道:
>
> Missing g_error_free() in sev_read_file_base64() error path.
> Fix that.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  target/i386/sev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index c3ecf86704..de4818da6d 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -500,6 +500,7 @@ sev_read_file_base64(const char *filename, guchar **data, gsize *len)
>
>      if (!g_file_get_contents(filename, &base64, &sz, &error)) {
>          error_report("failed to read '%s' (%s)", filename, error->message);
> +        g_error_free(error);
>          return -1;
>      }
>
> --
> 2.18.2
>
>
diff mbox series

Patch

diff --git a/target/i386/sev.c b/target/i386/sev.c
index c3ecf86704..de4818da6d 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -500,6 +500,7 @@  sev_read_file_base64(const char *filename, guchar **data, gsize *len)
 
     if (!g_file_get_contents(filename, &base64, &sz, &error)) {
         error_report("failed to read '%s' (%s)", filename, error->message);
+        g_error_free(error);
         return -1;
     }