inet: Ensure data->channel exist before accessing it
authorOtavio Salvador <otavio@ossystems.com.br>
Wed, 29 Feb 2012 08:20:24 +0000 (05:20 -0300)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 1 Mar 2012 12:45:25 +0000 (13:45 +0100)
Log of segfault:
...
connmand[676]: src/network.c:check_dhcpv6() reply (nil)
connmand[676]: src/network.c:check_dhcpv6() re-send router solicitation 3
connmand[676]: src/inet.c:__connman_inet_ipv6_send_rs()
connmand[676]: Aborting (signal 11) [connmand]

src/inet.c

index d9e12a9..220ea14 100644 (file)
@@ -1433,9 +1433,11 @@ static const struct in6_addr in6addr_all_routers_mc =
 
 static void rs_cleanup(struct rs_cb_data *data)
 {
-       g_io_channel_shutdown(data->channel, TRUE, NULL);
-       g_io_channel_unref(data->channel);
-       data->channel = 0;
+       if (data->channel != NULL) {
+               g_io_channel_shutdown(data->channel, TRUE, NULL);
+               g_io_channel_unref(data->channel);
+               data->channel = NULL;
+       }
 
        if (data->rs_timeout > 0)
                g_source_remove(data->rs_timeout);