diff mbox series

[PATCH-for-9.1,v2,4/4] hw/ssi/pnv_spi: Fixes Coverity CID 1558831

Message ID 20240807202804.56038-5-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
From: Chalapathi V <chalapathi.v@linux.ibm.com>

In this commit the following coverity scan defect has been fixed
CID 1558831:  Resource leaks  (RESOURCE_LEAK)
  Variable "rsp_payload" going out of scope leaks the storage it
  points to.

Fixes: Coverity CID 1558831
Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Fixes: b4cb930e40 ("hw/ssi: Extend SPI model")
[PMD: Rebased on previous commit (returning earlier)]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ssi/pnv_spi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé Aug. 7, 2024, 8:28 p.m. UTC | #1
On 7/8/24 22:28, Philippe Mathieu-Daudé wrote:
> From: Chalapathi V <chalapathi.v@linux.ibm.com>
> 
> In this commit the following coverity scan defect has been fixed
> CID 1558831:  Resource leaks  (RESOURCE_LEAK)
>    Variable "rsp_payload" going out of scope leaks the storage it
>    points to.
> 
> Fixes: Coverity CID 1558831
> Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
> Fixes: b4cb930e40 ("hw/ssi: Extend SPI model")

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> [PMD: Rebased on previous commit (returning earlier)]
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/ssi/pnv_spi.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
> index 05e6afc11e..eadc36fa86 100644
> --- a/hw/ssi/pnv_spi.c
> +++ b/hw/ssi/pnv_spi.c
> @@ -239,6 +239,7 @@ static void transfer(PnvSpi *s, PnvXferBuffer *payload)
>           }
>       }
>       spi_response(s, s->N1_bits, rsp_payload);
> +    pnv_spi_xfer_buffer_free(rsp_payload);
>   }
>   
>   static inline uint8_t get_seq_index(PnvSpi *s)
Richard Henderson Aug. 7, 2024, 11:45 p.m. UTC | #2
On 8/8/24 06:28, Philippe Mathieu-Daudé wrote:
> From: Chalapathi V<chalapathi.v@linux.ibm.com>
> 
> In this commit the following coverity scan defect has been fixed
> CID 1558831:  Resource leaks  (RESOURCE_LEAK)
>    Variable "rsp_payload" going out of scope leaks the storage it
>    points to.
> 
> Fixes: Coverity CID 1558831
> Signed-off-by: Chalapathi V<chalapathi.v@linux.ibm.com>
> Fixes: b4cb930e40 ("hw/ssi: Extend SPI model")
> [PMD: Rebased on previous commit (returning earlier)]
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/ssi/pnv_spi.c | 1 +
>   1 file changed, 1 insertion(+)

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 05e6afc11e..eadc36fa86 100644
--- a/hw/ssi/pnv_spi.c
+++ b/hw/ssi/pnv_spi.c
@@ -239,6 +239,7 @@  static void transfer(PnvSpi *s, PnvXferBuffer *payload)
         }
     }
     spi_response(s, s->N1_bits, rsp_payload);
+    pnv_spi_xfer_buffer_free(rsp_payload);
 }
 
 static inline uint8_t get_seq_index(PnvSpi *s)