diff mbox

loader: fix potential memory leak

Message ID 1456305167-19457-1-git-send-email-caoj.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Cao jin Feb. 24, 2016, 9:12 a.m. UTC
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 hw/core/loader.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Cao jin Feb. 25, 2016, 8:09 a.m. UTC | #1
sorry, It just came to me that I forgot to cc qemu-trivial

On 02/24/2016 05:12 PM, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>   hw/core/loader.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 3a57415..24fea65 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -827,10 +827,16 @@ int rom_add_file(const char *file, const char *fw_dir,
>   err:
>       if (fd != -1)
>           close(fd);
> +
>       g_free(rom->data);
>       g_free(rom->path);
>       g_free(rom->name);
> +    if (fw_dir) {
> +        g_free(rom->fw_dir);
> +        g_free(rom->fw_file);
> +    }
>       g_free(rom);
> +
>       return -1;
>   }
>
>
Michael Tokarev March 16, 2016, 11:39 a.m. UTC | #2
24.02.2016 12:12, Cao jin wrote:

> +    if (fw_dir) {
> +        g_free(rom->fw_dir);
> +        g_free(rom->fw_file);
> +    }

Applied to -trivial, thanks!

/mjt
diff mbox

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 3a57415..24fea65 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -827,10 +827,16 @@  int rom_add_file(const char *file, const char *fw_dir,
 err:
     if (fd != -1)
         close(fd);
+
     g_free(rom->data);
     g_free(rom->path);
     g_free(rom->name);
+    if (fw_dir) {
+        g_free(rom->fw_dir);
+        g_free(rom->fw_file);
+    }
     g_free(rom);
+
     return -1;
 }