2012-02-21 16:46:48

by Frédéric DALLEAU

[permalink] [raw]
Subject: [PATCH v2 0/2] gateway: Fix crash if SCO connection fails

Hi

The first patch is a resend of a previous patch with same name.
The second one happens after the sco connection has failed : the disconnect
watch is not removed when the media owner is freed upon error in acquire.

Let me know what you think.

Regards,
Frédéric


Frédéric Dalleau (2):
gateway: Fix crash if SCO connection fails
media: register disconnect watch at transport add

audio/gateway.c | 5 +----
audio/transport.c | 6 +++---
2 files changed, 4 insertions(+), 7 deletions(-)

--
1.7.5.4



2012-02-22 08:43:08

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] gateway: Fix crash if SCO connection fails

Hi Frederic,

2012/2/21 Fr?d?ric Dalleau <[email protected]>:
> In some situations, a connect callback is created, but
> this callback is not added to media_owner. Thus when the owner
> is destroyed and at rfcomm disconnect, the callback is executed
> with an invalid pointer.
> ---
> ?audio/gateway.c | ? ?5 +----
> ?1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/audio/gateway.c b/audio/gateway.c
> index 163f7b5..131f93f 100644
> --- a/audio/gateway.c
> +++ b/audio/gateway.c
> @@ -836,12 +836,9 @@ unsigned int gateway_request_stream(struct audio_device *dev,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?gateway_stream_cb_t cb, void *user_data)
> ?{
> ? ? ? ?struct gateway *gw = dev->gateway;
> - ? ? ? unsigned int id;
> ? ? ? ?GError *err = NULL;
> ? ? ? ?GIOChannel *io;
>
> - ? ? ? id = connect_cb_new(gw, cb, user_data);
> -
> ? ? ? ?if (!gw->rfcomm)
> ? ? ? ? ? ? ? ?get_records(dev);
> ? ? ? ?else if (!gw->sco) {
> @@ -858,7 +855,7 @@ unsigned int gateway_request_stream(struct audio_device *dev,
> ? ? ? ?} else
> ? ? ? ? ? ? ? ?g_idle_add(request_stream_cb, dev);
>
> - ? ? ? return id;
> + ? ? ? return connect_cb_new(gw, cb, user_data);
> ?}
>
> ?int gateway_config_stream(struct audio_device *dev, gateway_stream_cb_t cb,
> --
> 1.7.5.4

Ack

--
Luiz Augusto von Dentz

2012-02-22 08:42:20

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] media: register disconnect watch at transport add

Hi Frederic,

2012/2/21 Fr?d?ric Dalleau <[email protected]>:
> disconnect watch is not removed when the media owner is freed if
> an error occurs while resuming in acquire (id == 0).
> ---
> ?audio/transport.c | ? ?6 +++---
> ?1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/audio/transport.c b/audio/transport.c
> index b319e0e..7bf7309 100644
> --- a/audio/transport.c
> +++ b/audio/transport.c
> @@ -599,6 +599,9 @@ static void media_transport_add(struct media_transport *transport,
> ? ? ? ?DBG("Transport %s Owner %s", transport->path, owner->name);
> ? ? ? ?transport->owners = g_slist_append(transport->owners, owner);
> ? ? ? ?owner->transport = transport;
> + ? ? ? owner->watch = g_dbus_add_disconnect_watch(transport->conn, owner->name,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? media_owner_exit,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? owner, NULL);
> ?}
>
> ?static struct media_owner *media_owner_create(DBusConnection *conn,
> @@ -610,9 +613,6 @@ static struct media_owner *media_owner_create(DBusConnection *conn,
> ? ? ? ?owner = g_new0(struct media_owner, 1);
> ? ? ? ?owner->name = g_strdup(dbus_message_get_sender(msg));
> ? ? ? ?owner->accesstype = g_strdup(accesstype);
> - ? ? ? owner->watch = g_dbus_add_disconnect_watch(conn, owner->name,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? media_owner_exit,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? owner, NULL);
>
> ? ? ? ?DBG("Owner created: sender=%s accesstype=%s", owner->name,
> ? ? ? ? ? ? ? ? ? ? ? ?accesstype);
> --
> 1.7.5.4

Ack

--
Luiz Augusto von Dentz

2012-02-21 16:46:50

by Frédéric DALLEAU

[permalink] [raw]
Subject: [PATCH v2 2/2] media: register disconnect watch at transport add

disconnect watch is not removed when the media owner is freed if
an error occurs while resuming in acquire (id == 0).
---
audio/transport.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index b319e0e..7bf7309 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -599,6 +599,9 @@ static void media_transport_add(struct media_transport *transport,
DBG("Transport %s Owner %s", transport->path, owner->name);
transport->owners = g_slist_append(transport->owners, owner);
owner->transport = transport;
+ owner->watch = g_dbus_add_disconnect_watch(transport->conn, owner->name,
+ media_owner_exit,
+ owner, NULL);
}

static struct media_owner *media_owner_create(DBusConnection *conn,
@@ -610,9 +613,6 @@ static struct media_owner *media_owner_create(DBusConnection *conn,
owner = g_new0(struct media_owner, 1);
owner->name = g_strdup(dbus_message_get_sender(msg));
owner->accesstype = g_strdup(accesstype);
- owner->watch = g_dbus_add_disconnect_watch(conn, owner->name,
- media_owner_exit,
- owner, NULL);

DBG("Owner created: sender=%s accesstype=%s", owner->name,
accesstype);
--
1.7.5.4


2012-02-21 16:46:49

by Frédéric DALLEAU

[permalink] [raw]
Subject: [PATCH v2 1/2] gateway: Fix crash if SCO connection fails

In some situations, a connect callback is created, but
this callback is not added to media_owner. Thus when the owner
is destroyed and at rfcomm disconnect, the callback is executed
with an invalid pointer.
---
audio/gateway.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index 163f7b5..131f93f 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -836,12 +836,9 @@ unsigned int gateway_request_stream(struct audio_device *dev,
gateway_stream_cb_t cb, void *user_data)
{
struct gateway *gw = dev->gateway;
- unsigned int id;
GError *err = NULL;
GIOChannel *io;

- id = connect_cb_new(gw, cb, user_data);
-
if (!gw->rfcomm)
get_records(dev);
else if (!gw->sco) {
@@ -858,7 +855,7 @@ unsigned int gateway_request_stream(struct audio_device *dev,
} else
g_idle_add(request_stream_cb, dev);

- return id;
+ return connect_cb_new(gw, cb, user_data);
}

int gateway_config_stream(struct audio_device *dev, gateway_stream_cb_t cb,
--
1.7.5.4


2012-03-08 23:58:59

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] gateway: Fix crash if SCO connection fails

Hi Fr?d?ric,

On Tue, Feb 21, 2012, Fr?d?ric Dalleau wrote:
> The first patch is a resend of a previous patch with same name.
> The second one happens after the sco connection has failed : the disconnect
> watch is not removed when the media owner is freed upon error in acquire.
>
> Let me know what you think.
>
> Regards,
> Fr?d?ric
>
> Fr?d?ric Dalleau (2):
> gateway: Fix crash if SCO connection fails
> media: register disconnect watch at transport add
>
> audio/gateway.c | 5 +----
> audio/transport.c | 6 +++---
> 2 files changed, 4 insertions(+), 7 deletions(-)

Both patches have been applied. Thanks.

Johan

2012-03-08 10:14:38

by Dalleau, Frederic

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] gateway: Fix crash if SCO connection fails

Hi,

2012/2/21 Fr?d?ric Dalleau <[email protected]>:
> The first patch is a resend of a previous patch with same name.
> The second one happens after the sco connection has failed : the disconnect
> watch is not removed when the media owner is freed upon error in acquire.

Luiz acked, any updates please?

Thanks,
Fr?d?ric