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

STALE5314d

7 messages, 4 authors, 2012-03-08 · open the first message on its own page

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

From: Frédéric Dalleau <hidden>
Date: 2012-02-21 16:46:48

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

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

From: Frédéric Dalleau <hidden>
Date: 2012-02-21 16:46:49

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

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

From: Frédéric Dalleau <hidden>
Date: 2012-02-21 16:46:50

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

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

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2012-02-22 08:42:20

Hi Frederic,

2012/2/21 Frédéric Dalleau [off-list ref]:
quoted hunk
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

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

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2012-02-22 08:43:08

Hi Frederic,

2012/2/21 Frédéric Dalleau [off-list ref]:
quoted hunk
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

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

From: Dalleau, Frederic <hidden>
Date: 2012-03-08 10:14:38

Hi,

2012/2/21 Frédéric Dalleau [off-list ref]:
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

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

From: Johan Hedberg <hidden>
Date: 2012-03-08 23:58:59

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help