Skip to contentSkip to conversation

hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize

PATCH Superseded Caleb Schlossin 4 participants 5 messages Dec 16, 2025 – Jan 20

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize

unrealize should free the fifo8 memory that was allocated by realize.

Fixes 17befecda85 ("hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure")
---
 hw/ssi/pnv_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
index f40e8836b9..5db440be9a 100644
@@ -1176,6 +1176,13 @@ static void pnv_spi_realize(DeviceState *dev, Error **errp)
                           s, "xscom-spi", PNV10_XSCOM_PIB_SPIC_SIZE);
 }
 
+static void pnv_spi_unrealize(DeviceState *dev)
+{
+    PnvSpi *s = PNV_SPI(dev);
+    fifo8_destroy(&s->tx_fifo);
+    fifo8_destroy(&s->rx_fifo);
+}
+
 static int pnv_spi_dt_xscom(PnvXScomInterface *dev, void *fdt,
                              int offset)
 {
@@ -1208,6 +1215,7 @@ static void pnv_spi_class_init(ObjectClass *klass, const void *data)
 
     dc->desc = "PowerNV SPI";
     dc->realize = pnv_spi_realize;
+    dc->unrealize = pnv_spi_unrealize;
     device_class_set_legacy_reset(dc, do_reset);
     device_class_set_props(dc, pnv_spi_properties);
 }
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw

Thanks,

Glenn

Quoted 35 lines · Caleb Schlossin

unrealize should free the fifo8 memory that was allocated by realize.

Fixes 17befecda85 ("hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure")
---
 hw/ssi/pnv_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
index f40e8836b9..5db440be9a 100644
@@ -1176,6 +1176,13 @@ static void pnv_spi_realize(DeviceState *dev, Error **errp)
                           s, "xscom-spi", PNV10_XSCOM_PIB_SPIC_SIZE);
 }
 
+static void pnv_spi_unrealize(DeviceState *dev)
+{
+    PnvSpi *s = PNV_SPI(dev);
+    fifo8_destroy(&s->tx_fifo);
+    fifo8_destroy(&s->rx_fifo);
+}
+
 static int pnv_spi_dt_xscom(PnvXScomInterface *dev, void *fdt,
                              int offset)
 {
@@ -1208,6 +1215,7 @@ static void pnv_spi_class_init(ObjectClass *klass, const void *data)
 
     dc->desc = "PowerNV SPI";
     dc->realize = pnv_spi_realize;
+    dc->unrealize = pnv_spi_unrealize;
     device_class_set_legacy_reset(dc, do_reset);
     device_class_set_props(dc, pnv_spi_properties);
 }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Caleb Schlossin
Quoted 35 lines · Caleb Schlossin

unrealize should free the fifo8 memory that was allocated by realize.

Fixes 17befecda85 ("hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure")
---
  hw/ssi/pnv_spi.c | 8 ++++++++
  1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
index f40e8836b9..5db440be9a 100644
@@ -1176,6 +1176,13 @@ static void pnv_spi_realize(DeviceState *dev, Error **errp)
                            s, "xscom-spi", PNV10_XSCOM_PIB_SPIC_SIZE);
  }
 
+static void pnv_spi_unrealize(DeviceState *dev)
+{
+    PnvSpi *s = PNV_SPI(dev);
+    fifo8_destroy(&s->tx_fifo);
+    fifo8_destroy(&s->rx_fifo);
+}
+
  static int pnv_spi_dt_xscom(PnvXScomInterface *dev, void *fdt,
                               int offset)
  {
@@ -1208,6 +1215,7 @@ static void pnv_spi_class_init(ObjectClass *klass, const void *data)
 
      dc->desc = "PowerNV SPI";
      dc->realize = pnv_spi_realize;
+    dc->unrealize = pnv_spi_unrealize;
      device_class_set_legacy_reset(dc, do_reset);
      device_class_set_props(dc, pnv_spi_properties);
  }
#3 lore raw
In reply to Caleb Schlossin
Quoted 5 lines · Caleb Schlossin

unrealize should free the fifo8 memory that was allocated by realize.

Fixes 17befecda85 ("hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure")

Hello Caleb,

Sorry for the delayed review. The patch currently doesn't apply on upstream, as there was a merge conflict with vmstate patch and this.

Can you send a v2, rebased on upstream ?

Thank you,
- Aditya G

Quoted 33 lines
---
 hw/ssi/pnv_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
index f40e8836b9..5db440be9a 100644
@@ -1176,6 +1176,13 @@ static void pnv_spi_realize(DeviceState *dev, Error **errp)
                           s, "xscom-spi", PNV10_XSCOM_PIB_SPIC_SIZE);
 }
 
+static void pnv_spi_unrealize(DeviceState *dev)
+{
+    PnvSpi *s = PNV_SPI(dev);
+    fifo8_destroy(&s->tx_fifo);
+    fifo8_destroy(&s->rx_fifo);
+}
+
 static int pnv_spi_dt_xscom(PnvXScomInterface *dev, void *fdt,
                              int offset)
 {
@@ -1208,6 +1215,7 @@ static void pnv_spi_class_init(ObjectClass *klass, const void *data)
 
     dc->desc = "PowerNV SPI";
     dc->realize = pnv_spi_realize;
+    dc->unrealize = pnv_spi_unrealize;
     device_class_set_legacy_reset(dc, do_reset);
     device_class_set_props(dc, pnv_spi_properties);
 }
Signature · 1 line
2.47.3
#4 lore raw
Quoted 9 lines · Aditya Gupta
Quoted 5 lines · Caleb Schlossin

unrealize should free the fifo8 memory that was allocated by realize.

Fixes 17befecda85 ("hw/ssi/pnv_spi: Replace PnvXferBuffer with Fifo8 structure")

Hello Caleb,

Quoted 8 lines

Sorry for the delayed review. The patch currently doesn't apply on upstream, as there was a merge conflict with vmstate patch and this.

Can you send a v2, rebased on upstream ?

Thank you,
- Aditya G

Yup, I'll rebase and fix in v2.

Thanks,
Caleb

Quoted 33 lines
Quoted 33 lines
---
 hw/ssi/pnv_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
index f40e8836b9..5db440be9a 100644
@@ -1176,6 +1176,13 @@ static void pnv_spi_realize(DeviceState *dev, Error **errp)
                           s, "xscom-spi", PNV10_XSCOM_PIB_SPIC_SIZE);
 }
 
+static void pnv_spi_unrealize(DeviceState *dev)
+{
+    PnvSpi *s = PNV_SPI(dev);
+    fifo8_destroy(&s->tx_fifo);
+    fifo8_destroy(&s->rx_fifo);
+}
+
 static int pnv_spi_dt_xscom(PnvXScomInterface *dev, void *fdt,
                              int offset)
 {
@@ -1208,6 +1215,7 @@ static void pnv_spi_class_init(ObjectClass *klass, const void *data)
 
     dc->desc = "PowerNV SPI";
     dc->realize = pnv_spi_realize;
+    dc->unrealize = pnv_spi_unrealize;
     device_class_set_legacy_reset(dc, do_reset);
     device_class_set_props(dc, pnv_spi_properties);
 }
Signature · 1 line
2.47.3