Skip to contentSkip to conversation

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

PATCH In review Caleb Schlossin 2 participants 2 messages Jan 20 – Jan 24

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 76304d26fc..f3add8cab9 100644
@@ -1177,6 +1177,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)
 {
@@ -1234,6 +1241,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);
     dc->vmsd = &pnv_spi_vmstate;
     device_class_set_props(dc, pnv_spi_properties);
Signature · 1 line
2.47.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 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")

Looks good, thanks for rebasing and sending.

- Aditya G