thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-virtio-scsi-Plug-memory-leak-on-virtio_scsi_push_eve.patch

958e1b
From 56c66eefb296121eca5c78c7ab17215671712045 Mon Sep 17 00:00:00 2001
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Mon, 3 Nov 2014 04:56:41 +0100
958e1b
Subject: [PATCH 4/9] virtio-scsi: Plug memory leak on virtio_scsi_push_event()
958e1b
 error path
958e1b
958e1b
Message-id: <1414990601-21198-1-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 62029
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH] virtio-scsi: Plug memory leak on virtio_scsi_push_event() error path
958e1b
Bugzilla: 1088822
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
958e1b
958e1b
From: Markus Armbruster <armbru@redhat.com>
958e1b
958e1b
Spotted by Coverity.
958e1b
958e1b
calling virtqueue_pop() without checking VIRTIO_CONFIG_S_DRIVER_OK first
958e1b
is racy: we may use the queues before the guest set them up.
958e1b
958e1b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
958e1b
Cc: qemu-stable@nongnu.org
958e1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
(cherry picked from commit 91e7fcca4743cf694eb0c8e7a8d938cf359b5bd8)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/scsi/virtio-scsi.c | 3 ++-
958e1b
 1 file changed, 2 insertions(+), 1 deletion(-)
958e1b
958e1b
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
958e1b
index 7cf3e4b..35b3d65 100644
958e1b
--- a/hw/scsi/virtio-scsi.c
958e1b
+++ b/hw/scsi/virtio-scsi.c
958e1b
@@ -490,7 +490,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
958e1b
                                    uint32_t event, uint32_t reason)
958e1b
 {
958e1b
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
958e1b
-    VirtIOSCSIReq *req = virtio_scsi_pop_req(s, vs->event_vq);
958e1b
+    VirtIOSCSIReq *req;
958e1b
     VirtIOSCSIEvent *evt;
958e1b
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
958e1b
     int in_size;
958e1b
@@ -499,6 +499,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
958e1b
         return;
958e1b
     }
958e1b
 
958e1b
+    req = virtio_scsi_pop_req(s, vs->event_vq);
958e1b
     if (!req) {
958e1b
         s->events_dropped = true;
958e1b
         return;
958e1b
-- 
958e1b
1.8.3.1
958e1b