[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/66] vhost-user-scsi: Fix memleaks in vus_proc_req()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 01/66] vhost-user-scsi: Fix memleaks in vus_proc_req() |
Date: |
Tue, 8 Dec 2020 14:33:37 -0500 |
From: Alex Chen <alex.chen@huawei.com>
The 'elem' is allocated memory in vu_queue_pop(), and its memory should be
freed in all error branches after vu_queue_pop().
In addition, in order to free the 'elem' memory outside of while(1) loop, move
the definition of 'elem' to the beginning of vus_proc_req().
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <20201125013055.34147-1-alex.chen@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
contrib/vhost-user-scsi/vhost-user-scsi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c
b/contrib/vhost-user-scsi/vhost-user-scsi.c
index 0f9ba4b2a2..4639440a70 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -232,6 +232,7 @@ static void vus_proc_req(VuDev *vu_dev, int idx)
VugDev *gdev;
VusDev *vdev_scsi;
VuVirtq *vq;
+ VuVirtqElement *elem = NULL;
assert(vu_dev);
@@ -248,7 +249,6 @@ static void vus_proc_req(VuDev *vu_dev, int idx)
g_debug("Got kicked on vq[%d]@%p", idx, vq);
while (1) {
- VuVirtqElement *elem;
VirtIOSCSICmdReq *req;
VirtIOSCSICmdResp *rsp;
@@ -288,6 +288,7 @@ static void vus_proc_req(VuDev *vu_dev, int idx)
free(elem);
}
+ free(elem);
}
static void vus_queue_set_started(VuDev *vu_dev, int idx, bool started)
--
MST
- [PULL 00/66] pc,pci,virtio: fixes, cleanups, Michael S. Tsirkin, 2020/12/08
- [PULL 04/66] memory: Add IOMMU_NOTIFIER_DEVIOTLB_UNMAP IOMMUTLBNotificationType, Michael S. Tsirkin, 2020/12/08
- [PULL 02/66] memory: Rename memory_region_notify_one to memory_region_notify_iommu_one, Michael S. Tsirkin, 2020/12/08
- [PULL 01/66] vhost-user-scsi: Fix memleaks in vus_proc_req(),
Michael S. Tsirkin <=
- [PULL 03/66] memory: Add IOMMUTLBEvent, Michael S. Tsirkin, 2020/12/08
- [PULL 06/66] memory: Skip bad range assertion if notifier is DEVIOTLB_UNMAP type, Michael S. Tsirkin, 2020/12/08
- [PULL 05/66] intel_iommu: Skip page walking on device iotlb invalidations, Michael S. Tsirkin, 2020/12/08
- [PULL 08/66] acpi/gpex: Extract two APIs from acpi_dsdt_add_pci, Michael S. Tsirkin, 2020/12/08
- [PULL 07/66] virtio: reset device on bad guest index in virtio_load(), Michael S. Tsirkin, 2020/12/08
- [PULL 09/66] fw_cfg: Refactor extra pci roots addition, Michael S. Tsirkin, 2020/12/08
- [PULL 10/66] hw/arm/virt: Write extra pci roots into fw_cfg, Michael S. Tsirkin, 2020/12/08
- [PULL 11/66] acpi: Extract crs build form acpi_build.c, Michael S. Tsirkin, 2020/12/08
- [PULL 12/66] acpi/gpex: Build tables for pxb, Michael S. Tsirkin, 2020/12/08
- [PULL 14/66] unit-test: The files changed., Michael S. Tsirkin, 2020/12/08