diff mbox series

[2/2] nubus-device: ensure that name is freed after use in nubus_device_realize()

Message ID 20211002123101.14675-3-mark.cave-ayland@ilande.co.uk
State New
Headers show
Series nubus: a couple of Coverity fixes | expand

Commit Message

Mark Cave-Ayland Oct. 2, 2021, 12:31 p.m. UTC
Coverity points out that there is memory leak because name is never freed after
use in nubus_device_realize().

Fixes: Coverity CID 1464062
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/nubus/nubus-device.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé Oct. 2, 2021, 1:43 p.m. UTC | #1
On 10/2/21 14:31, Mark Cave-Ayland wrote:
> Coverity points out that there is memory leak because name is never freed after
> use in nubus_device_realize().
> 
> Fixes: Coverity CID 1464062
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/nubus/nubus-device.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Laurent Vivier Oct. 4, 2021, 6:50 a.m. UTC | #2
Le 02/10/2021 à 14:31, Mark Cave-Ayland a écrit :
> Coverity points out that there is memory leak because name is never freed after
> use in nubus_device_realize().
> 
> Fixes: Coverity CID 1464062
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/nubus/nubus-device.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
> index 0f1852f671..64f837e44d 100644
> --- a/hw/nubus/nubus-device.c
> +++ b/hw/nubus/nubus-device.c
> @@ -78,6 +78,7 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
>          name = g_strdup_printf("nubus-slot-%x-declaration-rom", nd->slot);
>          memory_region_init_rom(&nd->decl_rom, OBJECT(dev), name, size,
>                                 &error_abort);
> +        g_free(name);
>          ret = load_image_mr(path, &nd->decl_rom);
>          g_free(path);
>          if (ret < 0) {
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff mbox series

Patch

diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
index 0f1852f671..64f837e44d 100644
--- a/hw/nubus/nubus-device.c
+++ b/hw/nubus/nubus-device.c
@@ -78,6 +78,7 @@  static void nubus_device_realize(DeviceState *dev, Error **errp)
         name = g_strdup_printf("nubus-slot-%x-declaration-rom", nd->slot);
         memory_region_init_rom(&nd->decl_rom, OBJECT(dev), name, size,
                                &error_abort);
+        g_free(name);
         ret = load_image_mr(path, &nd->decl_rom);
         g_free(path);
         if (ret < 0) {