Both service and peer code store their data structures as ipconfig opaque
data, and therefore the respective code is the only entity that knows the
data structure stored.

Fix a potential crash by looking up the service by interface index
instead and leave the necessary check in place.
---
 src/ipconfig.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index ac783e5..0f548e3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -444,12 +444,9 @@ static void update_stats(struct connman_ipdevice *ipdevice,
        if (!ipdevice->config_ipv4 && !ipdevice->config_ipv6)
                return;
 
-       if (ipdevice->config_ipv4)
-               service = __connman_ipconfig_get_data(ipdevice->config_ipv4);
-       else if (ipdevice->config_ipv6)
-               service = __connman_ipconfig_get_data(ipdevice->config_ipv6);
-       else
-               return;
+       service = __connman_service_lookup_from_index(ipdevice->index);
+
+       DBG("service %p", service);
 
        if (!service)
                return;
-- 
2.1.4

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to