Richard Hughes <hughsi...@gmail.com> writes:

> On 22 May 2012 20:27, Sascha Silbe <si...@activitycentral.com> wrote:
>> CancelRequest() never worked because the method signature in D-Bus
>> introspection data didn't match the actual function signature.
>
> Patches look good, can you send them as attachments please? Thanks.

Sure, here they are. Thanks for the review!

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
From 7216bcd415cccfc8d02252495a7feef25df638b8 Mon Sep 17 00:00:00 2001
From: Sascha Silbe <si...@activitycentral.com>
Date: Tue, 22 May 2012 21:10:49 +0200
Subject: [PATCH upower 1/2] Fix use-after-free of qos item

up_qos_init() registers a destroyer callback for the qos item array,
so the current item will be gone after the calls to
g_ptr_array_remove(). By storing the item kind in a local variable we
can pass it to up_qos_latency_perhaps_changed() later. Delaying the
removal from the array is not an option as
up_qos_latency_perhaps_changed() scans that array to re-evaluate the
target latency.
---
 src/up-qos.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/up-qos.c b/src/up-qos.c
index 9484931..167ba2a 100644
--- a/src/up-qos.c
+++ b/src/up-qos.c
@@ -355,6 +355,7 @@ up_qos_cancel_request (UpQos *qos, guint cookie, DBusGMethodInvocation *context)
 	GError *error;
 	gchar *sender = NULL;
 	PolkitSubject *subject = NULL;
+	UpQosKind item_kind;
 
 	/* find the correct cookie */
 	item = up_qos_find_from_cookie (qos, cookie);
@@ -387,8 +388,9 @@ up_qos_cancel_request (UpQos *qos, guint cookie, DBusGMethodInvocation *context)
 	g_debug ("Clear #%i", cookie);
 
 	/* remove object from list */
+	item_kind = up_qos_item_get_kind (item);
 	g_ptr_array_remove (qos->priv->data, item);
-	up_qos_latency_perhaps_changed (qos, up_qos_item_get_kind (item));
+	up_qos_latency_perhaps_changed (qos, item_kind);
 
 	/* TODO: if persistent remove from datadase */
 
@@ -497,6 +499,7 @@ up_qos_remove_dbus (UpQos *qos, const gchar *sender)
 	guint i;
 	GPtrArray *data;
 	UpQosItem *item;
+	UpQosKind item_kind;
 
 	/* remove *any* senders that match the sender */
 	data = qos->priv->data;
@@ -504,8 +507,9 @@ up_qos_remove_dbus (UpQos *qos, const gchar *sender)
 		item = g_ptr_array_index (data, i);
 		if (strcmp (up_qos_item_get_sender (item), sender) == 0) {
 			g_debug ("Auto-revoked idle qos on %s", sender);
+			item_kind = up_qos_item_get_kind (item);
 			g_ptr_array_remove (qos->priv->data, item);
-			up_qos_latency_perhaps_changed (qos, up_qos_item_get_kind (item));
+			up_qos_latency_perhaps_changed (qos, item_kind);
 		}
 	}
 }
-- 
1.7.10

From ce3ed3dcccbfcfd454dacf8560e8c70dfd293540 Mon Sep 17 00:00:00 2001
From: Sascha Silbe <si...@activitycentral.com>
Date: Tue, 22 May 2012 21:11:07 +0200
Subject: [PATCH upower 2/2] Drop 'type' parameter from CancelRequest()
 signature

CancelRequest() never worked because the method signature in D-Bus
introspection data didn't match the actual function signature.

Since the 'type' parameter isn't needed by the implementation (cookies
are unique across all requests, not just requests of a certain type),
we drop it from the public API. This makes it easier for clients to
use the API as they only have to remember the cookie, not both cookie
and type. Since it never worked in the first place, there are no
backwards compatibility issues.
---
 src/org.freedesktop.UPower.QoS.xml |    8 --------
 1 file changed, 8 deletions(-)

diff --git a/src/org.freedesktop.UPower.QoS.xml b/src/org.freedesktop.UPower.QoS.xml
index 8e69f8a..400a0fc 100644
--- a/src/org.freedesktop.UPower.QoS.xml
+++ b/src/org.freedesktop.UPower.QoS.xml
@@ -164,14 +164,6 @@
     <!-- ************************************************************ -->
     <method name="CancelRequest">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-      <arg name="type" direction="in" type="s">
-        <doc:doc>
-          <doc:summary>
-            The type of latency to control, <doc:tt>cpu_dma</doc:tt> or
-            <doc:tt>network</doc:tt>.
-          </doc:summary>
-        </doc:doc>
-      </arg>
       <arg name="cookie" direction="in" type="u">
         <doc:doc>
           <doc:summary>
-- 
1.7.10

Attachment: pgpZJvcNqZnK6.pgp
Description: PGP signature

_______________________________________________
devkit-devel mailing list
devkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel

Reply via email to