[QEMU-DEVEL][PATCH] gpio: fix memory leak in aspeed_gpio_init()

pannengyuan@huawei.com posted 1 patch 4 years, 5 months ago
Test asan failed
Test checkpatch failed
Test FreeBSD failed
Test docker-mingw@fedora failed
Test docker-clang@ubuntu failed
Test docker-quick@centos7 failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1574041065-34936-1-git-send-email-pannengyuan@huawei.com
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Joel Stanley <joel@jms.id.au>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@aj.id.au>
hw/gpio/aspeed_gpio.c | 1 +
1 file changed, 1 insertion(+)
[QEMU-DEVEL][PATCH] gpio: fix memory leak in aspeed_gpio_init()
Posted by pannengyuan@huawei.com 4 years, 5 months ago
From: PanNengyuan <pannengyuan@huawei.com>

Address Sanitizer shows memory leak in hw/gpio/aspeed_gpio.c:875

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: PanNengyuan <pannengyuan@huawei.com>
---
 hw/gpio/aspeed_gpio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index 7acc5fa..41e11ea 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -876,6 +876,7 @@ static void aspeed_gpio_init(Object *obj)
                                pin_idx % GPIOS_PER_GROUP);
         object_property_add(obj, name, "bool", aspeed_gpio_get_pin,
                             aspeed_gpio_set_pin, NULL, NULL, NULL);
+        g_free(name);
     }
 }
 
-- 
2.7.2.windows.1



Re: [QEMU-DEVEL][PATCH] gpio: fix memory leak in aspeed_gpio_init()
Posted by Cédric Le Goater 4 years, 5 months ago
On 18/11/2019 02:37, pannengyuan@huawei.com wrote:
> From: PanNengyuan <pannengyuan@huawei.com>
> 
> Address Sanitizer shows memory leak in hw/gpio/aspeed_gpio.c:875
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: PanNengyuan <pannengyuan@huawei.com>

Reviewed-by: Cédric Le Goater <clg@kaod.org> 

I will add this patch the series I am building for 5.0.

Thanks,

C.

> ---
>  hw/gpio/aspeed_gpio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
> index 7acc5fa..41e11ea 100644
> --- a/hw/gpio/aspeed_gpio.c
> +++ b/hw/gpio/aspeed_gpio.c
> @@ -876,6 +876,7 @@ static void aspeed_gpio_init(Object *obj)
>                                 pin_idx % GPIOS_PER_GROUP);
>          object_property_add(obj, name, "bool", aspeed_gpio_get_pin,
>                              aspeed_gpio_set_pin, NULL, NULL, NULL);
> +        g_free(name);
>      }
>  }
>  
>