[PATCH] network: protect service structure access with reference

2014-12-18 Thread Hannu Mallat
As __connman_connection_gateway_remove() may unref service, wrap
network.c:set_disconnected() with connman_service_ref/unref to make
sure the struct stays around during the function call.
---
 src/network.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/network.c b/src/network.c
index b388995..de1464c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -703,6 +703,8 @@ static void set_disconnected(struct connman_network 
*network)
struct connman_service *service;
 
service = connman_service_lookup_from_network(network);
+   if (service)
+   connman_service_ref(service);
 
ipconfig_ipv4 = __connman_service_get_ip4config(service);
ipconfig_ipv6 = __connman_service_get_ip6config(service);
@@ -801,6 +803,9 @@ static void set_disconnected(struct connman_network 
*network)
network-connected = false;
 
connman_network_set_associating(network, false);
+
+   if (service)
+   connman_service_unref(service);
 }
 
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] network: protect service structure access with reference

2014-12-18 Thread Patrik Flykt
On Thu, 2014-12-18 at 10:14 +0200, Hannu Mallat wrote:
 As __connman_connection_gateway_remove() may unref service, wrap
 network.c:set_disconnected() with connman_service_ref/unref to make
 sure the struct stays around during the function call.

This looks like a mismatch between ref and unref in connection.c. If so,
the problem should be fixed there.

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman