[Spice-devel] [PATCH spice-gtk v2 17/33] fixup! usb-redir: add files for SCSI and USB MSC implementation
Frediano Ziglio
fziglio at redhat.com
Fri Aug 9 14:26:35 UTC 2019
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
More information about the Spice-devel
mailing list