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

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

 



Retain stream using reference counting.
Allow caller to free the object.
---
 src/cd-scsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cd-scsi.c b/src/cd-scsi.c
index f9e8441c..1cb268bf 100644
--- a/src/cd-scsi.c
+++ b/src/cd-scsi.c
@@ -433,6 +433,7 @@ void cd_scsi_target_free(CdScsiTarget *st)
         if (unit->realized) {
             cd_scsi_dev_unrealize(st, lun);
         }
+        g_clear_object(&unit->stream);
     }
     g_clear_object(&st->cancellable);
     g_free(st);
@@ -497,7 +498,7 @@ int cd_scsi_dev_realize(CdScsiTarget *st, uint32_t lun,
 static void cd_scsi_lu_media_reset(CdScsiLU *dev)
 {
     /* media_event is not set here, as it depends on the context */
-    dev->stream = NULL;
+    g_clear_object(&dev->stream);
     dev->size = 0;
     dev->block_size = 0;
     dev->num_blocks = 0;
@@ -526,7 +527,7 @@ static void cd_scsi_lu_load(CdScsiLU *dev,
 {
     if (media_params != NULL) {
         dev->media_event = CD_MEDIA_EVENT_NEW_MEDIA;
-        dev->stream = media_params->stream;
+        dev->stream = g_object_ref(media_params->stream);
         dev->size = media_params->size;
         dev->block_size = media_params->block_size;
         dev->num_blocks = media_params->size / media_params->block_size;
-- 
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]