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

Caleb Schlossin posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251216154503.2263755-1-calebs@linux.ibm.com
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Aditya Gupta <adityag@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, Alistair Francis <alistair@alistair23.me>
There is a newer version of this series
hw/ssi/pnv_spi.c | 8 ++++++++
1 file changed, 8 insertions(+)
[PATCH] hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
Posted by Caleb Schlossin 1 month, 3 weeks ago
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 <npiggin@gmail.com>
Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
---
 hw/ssi/pnv_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
index f40e8836b9..5db440be9a 100644
--- a/hw/ssi/pnv_spi.c
+++ b/hw/ssi/pnv_spi.c
@@ -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);
 }
-- 
2.47.3
Re: [PATCH] hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
Posted by Aditya Gupta 2 weeks, 5 days ago
On 25/12/16 09:45AM, Caleb Schlossin wrote:
> 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 <npiggin@gmail.com>
> Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>

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

> ---
>  hw/ssi/pnv_spi.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
> index f40e8836b9..5db440be9a 100644
> --- a/hw/ssi/pnv_spi.c
> +++ b/hw/ssi/pnv_spi.c
> @@ -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);
>  }
> -- 
> 2.47.3
>
Re: [PATCH] hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
Posted by Caleb Schlossin 2 weeks, 3 days ago

On 1/19/26 12:57 AM, Aditya Gupta wrote:
> On 25/12/16 09:45AM, Caleb Schlossin wrote:
>> 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 <npiggin@gmail.com>
>> Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
> 
> 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
> 

Yup, I'll rebase and fix in v2.

Thanks,
Caleb

>> ---
>>  hw/ssi/pnv_spi.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
>> index f40e8836b9..5db440be9a 100644
>> --- a/hw/ssi/pnv_spi.c
>> +++ b/hw/ssi/pnv_spi.c
>> @@ -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);
>>  }
>> -- 
>> 2.47.3
>>
Re: [PATCH] hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
Posted by Chalapathi V 1 month, 2 weeks ago
Reviewed-by: Chalapathi V<chalapathi.v@linux.ibm.com>

On 16/12/25 9:15 pm, Caleb Schlossin wrote:
> 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 <npiggin@gmail.com>
> Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
> ---
>   hw/ssi/pnv_spi.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
> index f40e8836b9..5db440be9a 100644
> --- a/hw/ssi/pnv_spi.c
> +++ b/hw/ssi/pnv_spi.c
> @@ -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);
>   }
Re: [PATCH] hw/ssi/pnv_spi: Fix fifo8 memory leak on unrealize
Posted by Miles Glenn 1 month, 3 weeks ago
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>

Thanks,

Glenn

On Tue, 2025-12-16 at 09:45 -0600, Caleb Schlossin wrote:
> 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 <npiggin@gmail.com>
> Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
> ---
>  hw/ssi/pnv_spi.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
> index f40e8836b9..5db440be9a 100644
> --- a/hw/ssi/pnv_spi.c
> +++ b/hw/ssi/pnv_spi.c
> @@ -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);
>  }