hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
PATCH 1/1 hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
unrealize should free the fifo8 memory that was allocated by realize.
--- hw/ssi/pnv_spi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/ssi/pnv_spi.c +8 -0
@@ -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
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")Signed-off-by Nicholas Piggin <[email protected]>Signed-off-by Caleb Schlossin <[email protected]>--- hw/ssi/pnv_spi.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/ssi/pnv_spi.c +8
-0@@ -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); }
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")Signed-off-by Nicholas Piggin <[email protected]>Signed-off-by Caleb Schlossin <[email protected]>--- hw/ssi/pnv_spi.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/ssi/pnv_spi.c +8
-0@@ -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); }
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")Signed-off-by Nicholas Piggin <[email protected]>Signed-off-by Caleb Schlossin <[email protected]>
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@@ -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
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")Signed-off-by Nicholas Piggin <[email protected]>Signed-off-by Caleb Schlossin <[email protected]>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@@ -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