qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 38/96] hw/ssi: Extend SPI model


From: Cédric Le Goater
Subject: Re: [PULL 38/96] hw/ssi: Extend SPI model
Date: Mon, 29 Jul 2024 14:08:51 +0200
User-agent: Mozilla Thunderbird

On 7/26/24 01:53, Nicholas Piggin wrote:
+static void transfer(PnvSpi *s, PnvXferBuffer *payload)
+{
+    uint32_t tx;
+    uint32_t rx;
+    PnvXferBuffer *rsp_payload = NULL;
+
+    rsp_payload = pnv_spi_xfer_buffer_new();
+    for (int offset = 0; offset < payload->len; offset += s->transfer_len) {
+        tx = 0;
+        for (int i = 0; i < s->transfer_len; i++) {
+            if ((offset + i) >= payload->len) {
+                tx <<= 8;
+            } else {
+                tx = (tx << 8) | payload->data[offset + i];
+            }
+        }
+        rx = ssi_transfer(s->ssi_bus, tx);
+        for (int i = 0; i < s->transfer_len; i++) {
+            if ((offset + i) >= payload->len) {
+                break;
+            }
+            *(pnv_spi_xfer_buffer_write_ptr(rsp_payload, rsp_payload->len, 1)) 
=
+                    (rx >> (8 * (s->transfer_len - 1) - i * 8)) & 0xFF;
+        }
+    }
+    if (rsp_payload != NULL) {
+        spi_response(s, s->N1_bits, rsp_payload);
+    }
+}

Coverity reports:

    CID 1558831:  Resource leaks  (RESOURCE_LEAK)
    Variable "rsp_payload" going out of scope leaks the storage it points to.


rsp_payload should be freed.

Thanks,

C.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]