Skip to contentSkip to conversation

nubus-device: fix memory leak in nubus_device_realize

PATCH In review Mauro Matteo Cascella 3 participants 4 messages Dec 22, 2022 – Jan 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nubus-device: fix memory leak in nubus_device_realize

Local variable "name" is allocated through strdup_printf and should be freed with g_free() to avoid memory leak.

Fixes 3616f424 ("nubus-device: add romfile property for loading declaration ROMs")
---
 hw/nubus/nubus-device.c | 1 +
 1 file changed, 1 insertion(+)
hw/nubus/nubus-device.c +1 -0
index 0f1852f671..49008e4938 100644
@@ -80,6 +80,7 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
                                &error_abort);
         ret = load_image_mr(path, &nd->decl_rom);
         g_free(path);
+        g_free(name);
         if (ret < 0) {
             error_setg(errp, "could not load romfile \"%s\"", nd->romfile);
             return;
Signature · 1 line
2.38.1
Reviewed-by on v1 1/1
#1 lore raw

Le 22/12/2022 à 18:29, Mauro Matteo Cascella a écrit :

Quoted 14 lines

Local variable "name" is allocated through strdup_printf and should be freed with g_free() to avoid memory leak.

Fixes 3616f424 ("nubus-device: add romfile property for loading declaration ROMs")
---
  hw/nubus/nubus-device.c | 1 +
  1 file changed, 1 insertion(+)
hw/nubus/nubus-device.c +0 -0
index 0f1852f671..49008e4938 100644

hw/nubus/nubus-device.c static void nubus_device_realize(DeviceState *dev, Error **errp) · line 86

Quoted 7 lines
hw/nubus/nubus-device.c +1 -0
@@ -80,6 +80,7 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
                                 &error_abort);
          ret = load_image_mr(path, &nd->decl_rom);
          g_free(path);
+        g_free(name);
          if (ret < 0) {
              error_setg(errp, "could not load romfile \"%s\"", nd->romfile);
              return;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Mauro Matteo Cascella
Quoted 8 lines · Mauro Matteo Cascella

Local variable "name" is allocated through strdup_printf and should be freed with g_free() to avoid memory leak.

Fixes 3616f424 ("nubus-device: add romfile property for loading declaration ROMs")
---
  hw/nubus/nubus-device.c | 1 +
  1 file changed, 1 insertion(+)
#3 lore raw
In reply to Mauro Matteo Cascella
Quoted 23 lines · Mauro Matteo Cascella

Local variable "name" is allocated through strdup_printf and should be freed with g_free() to avoid memory leak.

Fixes 3616f424 ("nubus-device: add romfile property for loading declaration ROMs")
---
 hw/nubus/nubus-device.c | 1 +
 1 file changed, 1 insertion(+)
hw/nubus/nubus-device.c +1 -1
index 0f1852f671..49008e4938 100644
@@ -80,6 +80,7 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
                                &error_abort);
         ret = load_image_mr(path, &nd->decl_rom);
         g_free(path);
+        g_free(name);
         if (ret < 0) {
             error_setg(errp, "could not load romfile \"%s\"", nd->romfile);
             return;
--
Quoted 1 line

2.38.1

Hi, any updates here? Is this patch going to be merged?

Thanks,

--
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0