Skip to contentSkip to conversation

Two simple Coverity defect patches

PATCH In review Markus Armbruster 2 participants 5 messages May 16, 2014

lore
Share & tools
lore
#0 lore raw

cover Two simple Coverity defect patches

Markus Armbruster (2):
scsi: Document intentional fall through in scsi_req_length()
virtio-scsi: Plug memory leak on virtio_scsi_push_event() error path

 hw/scsi/scsi-bus.c    | 2 ++
 hw/scsi/virtio-scsi.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 scsi: Document intentional fall through in scsi_req_length()

For clarity, and to hush up Coverity.

---
 hw/scsi/scsi-bus.c | 2 ++
 1 file changed, 2 insertions(+)
hw/scsi/scsi-bus.c +2 -0
index abe7302..06399fa 100644
@@ -938,6 +938,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
         if (cmd->xfer == 0) {
             cmd->xfer = 256;
         }
+        /* fall through */
     case WRITE_10:
     case WRITE_VERIFY_10:
     case WRITE_12:
@@ -952,6 +953,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
         if (cmd->xfer == 0) {
             cmd->xfer = 256;
         }
+        /* fall through */
     case READ_10:
     case RECOVER_BUFFERED_DATA:
     case READ_12:
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/2 virtio-scsi: Plug memory leak on virtio_scsi_push_event() error path

In reply to Markus Armbruster

Spotted by Coverity.

---
 hw/scsi/virtio-scsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/scsi/virtio-scsi.c +2 -1
index 1752193..14261fb 100644
@@ -498,7 +498,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
                                    uint32_t event, uint32_t reason)
 {
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
-    VirtIOSCSIReq *req = virtio_scsi_pop_req(s, vs->event_vq);
+    VirtIOSCSIReq *req;
     VirtIOSCSIEvent *evt;
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
     int in_size;
@@ -507,6 +507,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
         return;
     }
 
+    req = virtio_scsi_pop_req(s, vs->event_vq);
     if (!req) {
         s->events_dropped = true;
         return;
Signature · 1 line
1.8.1.4
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] virtio-scsi: Plug memory leak on virtio_scsi_push_event() error path

Il 16/05/2014 17:44, Markus Armbruster ha scritto:

Quoted 22 lines

Spotted by Coverity.

---
 hw/scsi/virtio-scsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/scsi/virtio-scsi.c +1 -1
index 1752193..14261fb 100644
@@ -498,7 +498,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
                                    uint32_t event, uint32_t reason)
 {
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
-    VirtIOSCSIReq *req = virtio_scsi_pop_req(s, vs->event_vq);
+    VirtIOSCSIReq *req;
     VirtIOSCSIEvent *evt;
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
     int in_size;

hw/scsi/virtio-scsi.c static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, · line 513

Quoted 7 lines
hw/scsi/virtio-scsi.c +1 -0
@@ -507,6 +507,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
         return;
     }
 
+    req = virtio_scsi_pop_req(s, vs->event_vq);
     if (!req) {
         s->events_dropped = true;
         return;
#4 lore raw
In reply to Markus Armbruster

Il 16/05/2014 17:44, Markus Armbruster ha scritto:

Quoted 7 lines

Markus Armbruster (2):
scsi: Document intentional fall through in scsi_req_length()
virtio-scsi: Plug memory leak on virtio_scsi_push_event() error path

 hw/scsi/scsi-bus.c    | 2 ++
 hw/scsi/virtio-scsi.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Thanks, applied (locally until the pending pull request is processed).

Paolo