diff mbox series

[PATCH-for-9.1,v2,2/4] hw/ssi/pnv_spi: Match _xfer_buffer_free() with _xfer_buffer_new()

Message ID 20240807202804.56038-3-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series hw/ssi/pnv_spi: Fixes Coverity CID 1558831 | expand

Commit Message

Philippe Mathieu-Daudé Aug. 7, 2024, 8:28 p.m. UTC
pnv_spi_xfer_buffer_new() allocates %payload using g_malloc0(),
and pnv_spi_xfer_buffer_write_ptr() allocates %payload->data
using g_realloc(). Use the API equivalent g_free() to release
the buffers.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ssi/pnv_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson Aug. 7, 2024, 11:44 p.m. UTC | #1
On 8/8/24 06:28, Philippe Mathieu-Daudé wrote:
> pnv_spi_xfer_buffer_new() allocates %payload using g_malloc0(),
> and pnv_spi_xfer_buffer_write_ptr() allocates %payload->data
> using g_realloc(). Use the API equivalent g_free() to release
> the buffers.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/ssi/pnv_spi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
> index c1297ab733..13a47f07e7 100644
> --- a/hw/ssi/pnv_spi.c
> +++ b/hw/ssi/pnv_spi.c
> @@ -53,8 +53,8 @@ static PnvXferBuffer *pnv_spi_xfer_buffer_new(void)
>   
>   static void pnv_spi_xfer_buffer_free(PnvXferBuffer *payload)
>   {
> -    free(payload->data);
> -    free(payload);
> +    g_free(payload->data);
> +    g_free(payload);
>   }
>   
>   static uint8_t *pnv_spi_xfer_buffer_write_ptr(PnvXferBuffer *payload,

g_free/free are supposed to be interchangeable in this epoch.

But
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
index c1297ab733..13a47f07e7 100644
--- a/hw/ssi/pnv_spi.c
+++ b/hw/ssi/pnv_spi.c
@@ -53,8 +53,8 @@  static PnvXferBuffer *pnv_spi_xfer_buffer_new(void)
 
 static void pnv_spi_xfer_buffer_free(PnvXferBuffer *payload)
 {
-    free(payload->data);
-    free(payload);
+    g_free(payload->data);
+    g_free(payload);
 }
 
 static uint8_t *pnv_spi_xfer_buffer_write_ptr(PnvXferBuffer *payload,