netconfig: Set netconfig_get_static6_gateway out param on success

Make sure to only set the netconfig_get_static6_gateway's out_mac
parameter on successful return and make sure to always set it, even if
to NULL.
This commit is contained in:
Andrew Zaborowski 2021-09-25 03:11:48 +02:00 committed by Denis Kenzior
parent d71a604385
commit 3021472358
1 changed files with 4 additions and 2 deletions

View File

@ -497,6 +497,7 @@ static struct l_rtnl_route *netconfig_get_static6_gateway(
{ {
L_AUTO_FREE_VAR(char *, gateway); L_AUTO_FREE_VAR(char *, gateway);
struct l_rtnl_route *ret; struct l_rtnl_route *ret;
const uint8_t *mac = NULL;
gateway = l_settings_get_string(netconfig->active_settings, gateway = l_settings_get_string(netconfig->active_settings,
"IPv6", "Gateway"); "IPv6", "Gateway");
@ -508,7 +509,7 @@ static struct l_rtnl_route *netconfig_get_static6_gateway(
netconfig->fils_override->ipv6_gateway); netconfig->fils_override->ipv6_gateway);
if (!l_memeqzero(netconfig->fils_override->ipv6_gateway_mac, 6)) if (!l_memeqzero(netconfig->fils_override->ipv6_gateway_mac, 6))
*out_mac = netconfig->fils_override->ipv6_gateway_mac; mac = netconfig->fils_override->ipv6_gateway_mac;
} else if (!gateway) } else if (!gateway)
return NULL; return NULL;
@ -522,6 +523,7 @@ static struct l_rtnl_route *netconfig_get_static6_gateway(
l_rtnl_route_set_priority(ret, ROUTE_PRIORITY_OFFSET); l_rtnl_route_set_priority(ret, ROUTE_PRIORITY_OFFSET);
l_rtnl_route_set_protocol(ret, RTPROT_STATIC); l_rtnl_route_set_protocol(ret, RTPROT_STATIC);
*out_mac = mac;
return ret; return ret;
} }
@ -863,7 +865,7 @@ static void netconfig_ipv6_ifaddr_add_cmd_cb(int error, uint16_t type,
{ {
struct netconfig *netconfig = user_data; struct netconfig *netconfig = user_data;
struct l_rtnl_route *gateway; struct l_rtnl_route *gateway;
const uint8_t *gateway_mac = NULL; const uint8_t *gateway_mac;
netconfig->addr6_add_cmd_id = 0; netconfig->addr6_add_cmd_id = 0;