[spice-server v3 11/14] qxl: Release QXL resources in red_put_surface_cmd

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

 



Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 server/display-channel.c |  3 ---
 server/red-parse-qxl.c   | 12 ++++++++----
 server/red-parse-qxl.h   |  1 +
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 0cc32813b..01835e965 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -286,7 +286,6 @@ static void stop_streams(DisplayChannel *display)
 void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
 {
     RedSurface *surface = &display->priv->surfaces[surface_id];
-    QXLInstance *qxl = display->priv->qxl;
     DisplayChannelClient *dcc;
 
     if (--surface->refs != 0) {
@@ -301,12 +300,10 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
 
     surface->context.canvas->ops->destroy(surface->context.canvas);
     if (surface->create_cmd != NULL) {
-        red_qxl_release_resource(qxl, surface->create_cmd->release_info_ext);
         red_surface_cmd_unref(surface->create_cmd);
         surface->create_cmd = NULL;
     }
     if (surface->destroy_cmd != NULL) {
-        red_qxl_release_resource(qxl, surface->destroy_cmd->release_info_ext);
         red_surface_cmd_unref(surface->destroy_cmd);
         surface->destroy_cmd = NULL;
     }
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 4c4bc4445..afa1e5be0 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1418,8 +1418,9 @@ bool red_validate_surface(uint32_t width, uint32_t height,
     return true;
 }
 
-static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
+static bool red_get_surface_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots, int group_id,
                                 RedSurfaceCmd *red, QXLPHYSICAL addr)
+
 {
     QXLSurfaceCmd *qxl;
     uint64_t size;
@@ -1430,6 +1431,7 @@ static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return false;
     }
+    red->qxl = qxl_instance;
     red->release_info_ext.info      = &qxl->release_info;
     red->release_info_ext.group_id  = group_id;
 
@@ -1462,7 +1464,9 @@ static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
 
 static void red_put_surface_cmd(RedSurfaceCmd *red)
 {
-    /* nothing yet */
+    if (red->qxl) {
+        red_qxl_release_resource(red->qxl, red->release_info_ext);
+    }
 }
 
 RedSurfaceCmd *red_surface_cmd_new(QXLInstance *qxl_instance, RedMemSlotInfo *slots,
@@ -1474,8 +1478,8 @@ RedSurfaceCmd *red_surface_cmd_new(QXLInstance *qxl_instance, RedMemSlotInfo *sl
 
     cmd->refs = 1;
 
-    if (!red_get_surface_cmd(slots, group_id, cmd, addr)) {
-        g_free(cmd);
+    if (!red_get_surface_cmd(qxl_instance, slots, group_id, cmd, addr)) {
+        red_surface_cmd_unref(cmd);
         return NULL;
     }
 
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index 37e4ffb21..43ace663b 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -85,6 +85,7 @@ typedef struct RedSurfaceCreate {
 } RedSurfaceCreate;
 
 typedef struct RedSurfaceCmd {
+    QXLInstance *qxl;
     QXLReleaseInfoExt release_info_ext;
     int refs;
     uint32_t surface_id;
-- 
2.14.3

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




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