[PATCH spice-gtk v2 17/33] fixup! usb-redir: add files for SCSI and USB MSC implementation

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

 



Free all possible data in cd_scsi_target_free.
Avoid some leaks.
---
 src/cd-scsi.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/cd-scsi.c b/src/cd-scsi.c
index 66e4ddef..f9e8441c 100644
--- a/src/cd-scsi.c
+++ b/src/cd-scsi.c
@@ -423,10 +423,19 @@ CdScsiTarget *cd_scsi_target_alloc(void *target_user_data, uint32_t max_luns)
     return st;
 }
 
-void cd_scsi_target_free(CdScsiTarget *scsi_target)
+void cd_scsi_target_free(CdScsiTarget *st)
 {
-    cd_scsi_target_reset(scsi_target);
-    g_free(scsi_target);
+    uint32_t lun;
+
+    cd_scsi_target_reset(st);
+    for (lun = 0; lun < st->max_luns; lun++) {
+        CdScsiLU *unit = &st->units[lun];
+        if (unit->realized) {
+            cd_scsi_dev_unrealize(st, lun);
+        }
+    }
+    g_clear_object(&st->cancellable);
+    g_free(st);
 }
 
 /* SCSI Device */
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]