summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-09-03 19:48:20 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-09-03 19:48:20 +0000
commitc4915300a7d0493d64578bfc3b2b4b35a3d5ee0f (patch)
tree5da140cd9999a1a3f9617935a95fcf34e14ed6a6
parenta229e05f0a28860e766034f04ca5086f0e355045 (diff)
Fix double call to rfcomm_release() and rfcomm_node_free()
-rw-r--r--hcid/dbus-rfcomm.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/hcid/dbus-rfcomm.c b/hcid/dbus-rfcomm.c
index 0fba2226..90027a81 100644
--- a/hcid/dbus-rfcomm.c
+++ b/hcid/dbus-rfcomm.c
@@ -87,10 +87,6 @@ static char *rfcomm_node_name_from_id(int16_t id, char *dev, size_t len)
static void rfcomm_node_free(struct rfcomm_node *node)
{
- if (node->io) {
- g_io_remove_watch(node->io_id);
- g_io_channel_unref(node->io);
- }
if (node->owner)
free(node->owner);
free(node);
@@ -198,6 +194,7 @@ static gboolean rfcomm_disconnect_cb(GIOChannel *io, GIOCondition cond,
{
debug("RFCOMM node %s was disconnected", node->name);
connected_nodes = slist_remove(connected_nodes, node);
+ g_io_channel_unref(node->io);
rfcomm_node_free(node);
return FALSE;
}
@@ -248,6 +245,7 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan, GIOCondition cond,
error_failed(c->conn, c->msg, ENOMEM);
goto failed;
}
+ memset(node, 0, sizeof(*node));
/* Create the rfcomm device node */
memset(&req, 0, sizeof(req));
@@ -282,9 +280,6 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan, GIOCondition cond,
err = errno;
error("Could not open %s: %s (%d)", node->name,
strerror(err), err);
- rfcomm_release(node, NULL);
- rfcomm_node_free(node);
-
error_connection_attempt_failed(c->conn, c->msg, err);
goto failed;
}
@@ -324,7 +319,8 @@ failed:
if (fd >= 0)
close(fd);
if (node) {
- rfcomm_release(node, NULL);
+ if (node->id >= 0)
+ rfcomm_release(node, NULL);
rfcomm_node_free(node);
}
if (reply)