hw/ssi/pnv_spi: Fixes Coverity CID 1558831
v2 cover hw/ssi/pnv_spi: Fixes Coverity CID 1558831
v2:
- Cover PowerNV SSI in MAINTAINERS
- Use GLib API in pnv_spi_xfer_buffer_free()
- Simplify returning early
Supersedes: <[email protected]>
Chalapathi V (1):
hw/ssi/pnv_spi: Fixes Coverity CID 1558831
Philippe Mathieu-Daudé (3):
MAINTAINERS: Cover PowerPC SPI model in PowerNV section hw/ssi/pnv_spi: Match _xfer_buffer_free() with _xfer_buffer_new() hw/ssi/pnv_spi: Return early in transfer()
MAINTAINERS | 2 ++ hw/ssi/pnv_spi.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.45.2
PATCH v2 1/4 MAINTAINERS: Cover PowerPC SPI model in PowerNV section
It is unfair to let the PowerNV SPI model to the SSI maintainers. Also include the PowerNV ones.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -1542,8 +1542,10 @@ F: hw/ppc/pnv* F: hw/intc/pnv* F: hw/intc/xics_pnv.c F: hw/pci-host/pnv* +F: hw/ssi/pnv_spi.c F: include/hw/ppc/pnv* F: include/hw/pci-host/pnv* +F: hw/ssi/pnv_spi* F: pc-bios/skiboot.lid F: tests/qtest/pnv*
Signature · 1 line
2.45.2
PATCH v2 2/4 hw/ssi/pnv_spi: Match _xfer_buffer_free() with _xfer_buffer_new()
In reply to Philippe Mathieu-Daudé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.
--- hw/ssi/pnv_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ssi/pnv_spi.c +2 -2
@@ -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,
Signature · 1 line
2.45.2
Re: [PATCH-for-9.1 v2 2/4] hw/ssi/pnv_spi: Match _xfer_buffer_free() with _xfer_buffer_new()
Quoted 15 lines · Philippe Mathieu-Daudé
pnv_spi_xfer_buffer_new()allocates %payload usingg_malloc0(), andpnv_spi_xfer_buffer_write_ptr()allocates %payload->data usingg_realloc(). Use the API equivalentg_free()to release the buffers.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/ssi/pnv_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/ssi/pnv_spi.c +0
-0
hw/ssi/pnv_spi.c static PnvXferBuffer *pnv_spi_xfer_buffer_new(void) · line 60
Quoted 10 lines
hw/ssi/pnv_spi.c +2
-2@@ -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
r~
PATCH v2 3/4 hw/ssi/pnv_spi: Return early in transfer()
In reply to Philippe Mathieu-DaudéReturn early to simplify next commit.
No logical change intended.
--- hw/ssi/pnv_spi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/ssi/pnv_spi.c +4 -3
@@ -217,6 +217,9 @@ static void transfer(PnvSpi *s, PnvXferBuffer *payload)PnvXferBuffer *rsp_payload =NULL ; rsp_payload =pnv_spi_xfer_buffer_new (); +if (!rsp_payload) { +return ; + }for (int offset =0 ; offset < payload->len; offset += s->transfer_len) { tx =0 ;for (int i =0 ; i < s->transfer_len; i++) {
@@ -235,9 +238,7 @@ static void transfer(PnvSpi *s, PnvXferBuffer *payload) (rx >> (8 * (s->transfer_len -1 ) - i *8 )) &0xFF ; } } -if (rsp_payload !=NULL ) { -spi_response (s, s->N1_bits, rsp_payload); - } +spi_response (s, s->N1_bits, rsp_payload); }static inline uint8_t get_seq_index (PnvSpi *s)
Signature · 1 line
2.45.2
Re: [PATCH-for-9.1 v2 3/4] hw/ssi/pnv_spi: Return early in transfer()
Quoted 13 lines · Philippe Mathieu-Daudé
Return early to simplify next commit.
No logical change intended.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/ssi/pnv_spi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)hw/ssi/pnv_spi.c +0
-0
hw/ssi/pnv_spi.c static void transfer(PnvSpi *s, PnvXferBuffer *payload) · line 219
Quoted 3 lines
hw/ssi/pnv_spi.c +0
-0@@ -217,6 +217,9 @@ static void transfer(PnvSpi *s, PnvXferBuffer *payload)PnvXferBuffer *rsp_payload =NULL ; rsp_payload =pnv_spi_xfer_buffer_new ();
this uses g_malloc0
hw/ssi/pnv_spi.c static void transfer(PnvSpi *s, PnvXferBuffer *payload) · line 222
Quoted 3 lines
hw/ssi/pnv_spi.c +3
-0+if (!rsp_payload) { +return ; + }
so this will never fail.
hw/ssi/pnv_spi.c static void transfer(PnvSpi *s, PnvXferBuffer *payload) · line 242
Quoted 12 lines
hw/ssi/pnv_spi.c +1
-3for (int offset =0 ; offset < payload->len; offset += s->transfer_len) { tx =0 ;for (int i =0 ; i < s->transfer_len; i++) {@@ -235,9 +238,7 @@ static void transfer(PnvSpi *s, PnvXferBuffer *payload) (rx >> (8 * (s->transfer_len -1 ) - i *8 )) &0xFF ; } } -if (rsp_payload !=NULL ) { -spi_response (s, s->N1_bits, rsp_payload); - } +spi_response (s, s->N1_bits, rsp_payload); }
The cleanup could simply be this hunk.
r~
PATCH v2 4/4 hw/ssi/pnv_spi: Fixes Coverity CID 1558831
In reply to Philippe Mathieu-DaudéFrom: Chalapathi V <[email protected]>
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.
--- hw/ssi/pnv_spi.c | 1 + 1 file changed, 1 insertion(+)
hw/ssi/pnv_spi.c +1 -0
@@ -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)
Signature · 1 line
2.45.2
Quoted 10 lines · Philippe Mathieu-Daudé
From: Chalapathi V <[email protected]>
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 1558831Signed-off-by Chalapathi V <[email protected]>Fixes b4cb930e40 ("hw/ssi: Extend SPI model")
Quoted 18 lines
[PMD: Rebased on previous commit (returning earlier)]Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/ssi/pnv_spi.c | 1 + 1 file changed, 1 insertion(+)hw/ssi/pnv_spi.c +1
-0@@ -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)
Quoted 7 lines · Philippe Mathieu-Daudé
From: Chalapathi V<[email protected]>
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.
Quoted 8 lines
Fixes Coverity CID 1558831Signed-off-by Chalapathi V<[email protected]>Fixes b4cb930e40 ("hw/ssi: Extend SPI model")[PMD: Rebased on previous commit (returning earlier)]Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/ssi/pnv_spi.c | 1 + 1 file changed, 1 insertion(+)
r~
Chalapthi,
Quoted 6 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
I was wondering where we were on this series. I see there were comments on the initial one that would need some response at least. Do you have plans for a respin ?
Thanks,
C.
Quoted 12 lines
Chalapathi V (1):
hw/ssi/pnv_spi: Fixes Coverity CID 1558831Philippe Mathieu-Daudé (3):
MAINTAINERS: Cover PowerPC SPI model in PowerNV section hw/ssi/pnv_spi: Match_xfer_buffer_free()with_xfer_buffer_new()hw/ssi/pnv_spi: Return early intransfer()MAINTAINERS | 2 ++ hw/ssi/pnv_spi.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-)
Quoted 10 lines · Cédric Le Goater
Chalapthi,
Quoted 6 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
Quoted 8 lines
I was wondering where we were on this series. I see there were comments on the initial one that would need some response at least. Do you have plans for a respin ?
Thanks,
C.
Hello Cedric,
Thank You so much for reminding me. I apologize for not getting back on this sooner. I am working on the review comments from initial v1 patchset and send the v2 patchset ASAP.
Thank You,
Chalapathi
Quoted 15 lines
Quoted 13 lines
Chalapathi V (1):
hw/ssi/pnv_spi: Fixes Coverity CID 1558831Philippe Mathieu-Daudé (3):
MAINTAINERS: Cover PowerPC SPI model in PowerNV section hw/ssi/pnv_spi: Match_xfer_buffer_free()with_xfer_buffer_new()hw/ssi/pnv_spi: Return early intransfer()MAINTAINERS | 2 ++
hw/ssi/pnv_spi.c| 12 +++++++-----2 files changed, 9 insertions(+), 5 deletions(-)
Hello,
Quoted 16 lines · Chalapathi V
Quoted 14 lines · Cédric Le Goater
Chalapthi,
Quoted 6 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
I was wondering where we were on this series. I see there were comments on the initial one that would need some response at least. Do you have plans for a respin ?
Quoted 7 lines
Quoted 4 lines
Thanks,
C.
Hello Cedric,
Thank You so much for reminding me. I apologize for not getting back on this sooner.
That's fine. We have some spare time before the QEMU 9.2 cycle closes. I'd say ~2 months. Still, it would be good to address these issues before adding more models (Dan's TPM device model) relying on it.
Quoted 1 line
I am working on the review comments from initial v1 patchset and send the v2 patchset ASAP.
That would be a v3 ? Since Philippe sent a v2.
Thanks,
C.
Quoted 23 lines · Cédric Le Goater
Hello,
Quoted 20 lines · Chalapathi V
Quoted 18 lines · Cédric Le Goater
Chalapthi,
Quoted 6 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
I was wondering where we were on this series. I see there were comments on the initial one that would need some response at least. Do you have plans for a respin ?
Thanks,
C.
Quoted 8 lines
Quoted 3 lines
Hello Cedric,
Thank You so much for reminding me. I apologize for not getting back on this sooner.
That's fine. We have some spare time before the QEMU 9.2 cycle closes. I'd say ~2 months. Still, it would be good to address these issues before adding more models (Dan's TPM device model) relying on it.
Sure. Thank You.
Quoted 8 lines
Quoted 2 lines
I am working on the review comments from initial v1 patchset and send the v2 patchset ASAP.
That would be a v3 ? Since Philippe sent a v2.
Thanks,
C.
Sure. Will send v3 for the series: hw/ssi/pnv_spi: Fixes Coverity CID 1558831 and
a separate series for resolving Coverity CID 1558827.
Thank You,
Chalapathi
Quoted 7 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
Quoted 7 lines
Chalapathi V (1):
hw/ssi/pnv_spi: Fixes Coverity CID 1558831Philippe Mathieu-Daudé (3):
MAINTAINERS: Cover PowerPC SPI model in PowerNV section hw/ssi/pnv_spi: Match_xfer_buffer_free()with_xfer_buffer_new()hw/ssi/pnv_spi: Return early intransfer()
Note that I included this series in the ppc 9.2 PR, because Chalapathi has not found time to finish the better rework. There were a couple of comments about style / unnecessary code for these, but that will all get replaced by the rework so I prefer to leave unchanged. Thanks all for the help with this.
Thanks,
Nick
Quoted 16 lines · Nicholas Piggin
Quoted 7 lines · Philippe Mathieu-Daudé
v2:
- Cover PowerNV SSI inMAINTAINERS
- Use GLib API inpnv_spi_xfer_buffer_free()
- Simplify returning earlySupersedes: <[email protected]>
Quoted 7 lines
Chalapathi V (1):
hw/ssi/pnv_spi: Fixes Coverity CID 1558831Philippe Mathieu-Daudé (3):
MAINTAINERS: Cover PowerPC SPI model in PowerNV section hw/ssi/pnv_spi: Match_xfer_buffer_free()with_xfer_buffer_new()hw/ssi/pnv_spi: Return early intransfer()
Quoted 5 lines
Note that I included this series in the ppc 9.2 PR, because Chalapathi has not found time to finish the better rework. There were a couple of comments about style / unnecessary code for these, but that will all get replaced by the rework so I prefer to leave unchanged. Thanks all for the help with this.
Thanks Nick!