diff mbox

hw/arm/virt: Fix corruption due to double free

Message ID 1427944026-8968-1-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao April 2, 2015, 3:07 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

As 4de9a88(hw/arm/virt: Fix memory leak reported by Coverity)
and 6e05a12(arm: fix memory leak) both handle the memory leak
reported by Coverity, this cause qemu corruption due to
double free.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/arm/virt.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

Comments

Peter Maydell April 2, 2015, 9:29 a.m. UTC | #1
On 2 April 2015 at 04:07, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> As 4de9a88(hw/arm/virt: Fix memory leak reported by Coverity)
> and 6e05a12(arm: fix memory leak) both handle the memory leak
> reported by Coverity, this cause qemu corruption due to
> double free.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 7d082e2..febff22 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -572,7 +572,6 @@ static void create_flash(const VirtBoardInfo *vbi)
>              error_report("Could not load ROM image '%s'", bios_name);
>              exit(1);
>          }
> -        g_free(fn);
>      }
>
>      create_one_flash("virt.flash0", flashbase, flashsize);

Oops, yes. vexpress.c has the same double-free too.

-- PMM
Stefan Weil April 2, 2015, 10:51 a.m. UTC | #2
Am 02.04.2015 um 05:07 schrieb Shannon Zhao:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> As 4de9a88(hw/arm/virt: Fix memory leak reported by Coverity)
> and 6e05a12(arm: fix memory leak) both handle the memory leak
> reported by Coverity, this cause qemu corruption due to
> double free.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 7d082e2..febff22 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -572,7 +572,6 @@ static void create_flash(const VirtBoardInfo *vbi)
>              error_report("Could not load ROM image '%s'", bios_name);
>              exit(1);
>          }
> -        g_free(fn);
>      }
>  
>      create_one_flash("virt.flash0", flashbase, flashsize);

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Gonglei (Arei) April 2, 2015, 11:14 a.m. UTC | #3
On 2015/4/2 11:07, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> As 4de9a88(hw/arm/virt: Fix memory leak reported by Coverity)
> and 6e05a12(arm: fix memory leak) both handle the memory leak
> reported by Coverity, this cause qemu corruption due to
> double free.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 7d082e2..febff22 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -572,7 +572,6 @@ static void create_flash(const VirtBoardInfo *vbi)
>              error_report("Could not load ROM image '%s'", bios_name);
>              exit(1);
>          }
> -        g_free(fn);
>      }
>  
>      create_one_flash("virt.flash0", flashbase, flashsize);
> 
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Peter Maydell April 2, 2015, 11:50 a.m. UTC | #4
On 2 April 2015 at 04:07, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> As 4de9a88(hw/arm/virt: Fix memory leak reported by Coverity)
> and 6e05a12(arm: fix memory leak) both handle the memory leak
> reported by Coverity, this cause qemu corruption due to
> double free.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)

Applied to master, thanks.

-- PMM
diff mbox

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 7d082e2..febff22 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -572,7 +572,6 @@  static void create_flash(const VirtBoardInfo *vbi)
             error_report("Could not load ROM image '%s'", bios_name);
             exit(1);
         }
-        g_free(fn);
     }
 
     create_one_flash("virt.flash0", flashbase, flashsize);