@@ -1830,8 +1830,7 @@ int __connman_connection_gateway_add(struct connman_service *service,
struct gateway_data *new_gateway = NULL;
enum connman_ipconfig_type type4 = CONNMAN_IPCONFIG_TYPE_UNKNOWN,
type6 = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
- enum connman_service_type service_type =
- connman_service_get_type(service);
+ enum connman_service_type service_type;
int index;
g_autofree char *interface = NULL;
int err = 0;
@@ -1842,12 +1841,17 @@ int __connman_connection_gateway_add(struct connman_service *service,
type, __connman_ipconfig_type2string(type),
peer, maybe_null(peer));
+ if (!service)
+ return -EINVAL;
+
index = __connman_service_get_index(service);
interface = connman_inet_ifname(index);
DBG("index %d (%s)", index, maybe_null(interface));
+ service_type = connman_service_get_type(service);
+
/*
* If gateway is NULL, it's a point to point link and the default
* gateway for ipv4 is 0.0.0.0 and for ipv6 is ::, meaning the
From: Grant Erickson <erick205@umn.edu> In '__connman_connection_gateway_add', as an internal, cross-module function, check that the 'service' parameter is not null. If it is, return -EINVAL. --- src/connection.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)