[PATCH 2/5] serial: fix unref of dbus message

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

 



From: "Gustavo F. Padovan" <padovan@xxxxxxxxxxxxxx>

port->msg needs unref when the reply is sent.
---
 serial/port.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/serial/port.c b/serial/port.c
index e359716..3f041a6 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -204,6 +204,11 @@ static void serial_port_free(void *data)
 
 	port_release(port);
 
+	if (port->msg) {
+		dbus_message_unref(port->msg);
+		port->msg = NULL;
+	}
+
 	g_free(port->uuid);
 	g_free(port);
 }
@@ -224,6 +229,11 @@ static void port_owner_exited(DBusConnection *conn, void *user_data)
 
 	port_release(port);
 
+	if (port->msg) {
+		dbus_message_unref(port->msg);
+		port->msg = NULL;
+	}
+
 	port->listener_id = 0;
 }
 
@@ -261,6 +271,8 @@ static void open_notify(int fd, int err, struct serial_port *port)
 
 	/* Reply to the requestor */
 	g_dbus_send_message(device->conn, reply);
+	dbus_message_unref(port->msg);
+	port->msg = NULL;
 }
 
 static gboolean open_continue(gpointer user_data)
@@ -339,6 +351,8 @@ static void rfcomm_connect_cb(GIOChannel *chan, GError *conn_err,
 				DBUS_TYPE_UNIX_FD, &sk,
 				DBUS_TYPE_INVALID);
 		g_dbus_send_message(device->conn, reply);
+		dbus_message_unref(port->msg);
+		port->msg = NULL;
 		return;
 	}
 
@@ -368,6 +382,8 @@ static void rfcomm_connect_cb(GIOChannel *chan, GError *conn_err,
 
 fail:
 	g_dbus_send_message(device->conn, reply);
+	dbus_message_unref(port->msg);
+	port->msg = NULL;
 	g_dbus_remove_watch(device->conn, port->listener_id);
 	port->listener_id = 0;
 }
@@ -431,6 +447,8 @@ failed:
 	g_dbus_remove_watch(device->conn, port->listener_id);
 	port->listener_id = 0;
 	g_dbus_send_message(device->conn, reply);
+	dbus_message_unref(port->msg);
+	port->msg = NULL;
 }
 
 static int connect_port(struct serial_port *port)
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux