Fix possible memory leak when closing control channel.

This commit is contained in:
Luiz Augusto von Dentz 2008-04-30 19:37:46 +00:00
parent c13abd60b0
commit 2d5441331d
2 changed files with 5 additions and 3 deletions

View File

@ -580,6 +580,7 @@ static void interrupt_connect_cb(GIOChannel *chan, int err, gpointer user_data)
dbus_message_new_method_return(idev->pending_connect));
goto cleanup;
failed:
error_connection_attempt_failed(idev->conn,
idev->pending_connect, -err);

View File

@ -62,7 +62,7 @@ struct pending_req {
DBusMessage *msg;
sdp_list_t *pnp_recs;
sdp_list_t *hid_recs;
int ctrl_sock;
GIOChannel *ctrl_channel;
};
static GSList *device_paths = NULL; /* Input registered paths */
@ -259,7 +259,8 @@ failed:
error_connection_attempt_failed(pr->conn, pr->msg, err);
cleanup:
close(pr->ctrl_sock);
g_io_channel_close(pr->ctrl_channel);
g_io_channel_unref(pr->ctrl_channel);
g_io_channel_close(chan);
g_io_channel_unref(chan);
pending_req_free(pr);
@ -278,7 +279,7 @@ static void control_connect_cb(GIOChannel *chan, int err, gpointer user_data)
}
/* Set HID control channel */
pr->ctrl_sock = g_io_channel_unix_get_fd(chan);
pr->ctrl_channel = chan;
/* Connect to the HID interrupt channel */
err = bt_l2cap_connect(&pr->src, &pr->dst, L2CAP_PSM_HIDP_INTR,