From 8c744b66cc540d8ecddee51cdab2c910945dd840 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 10 Dec 2018 08:29:46 +0100 Subject: [PATCH] core: avoid calling platform code with invalid ifindex (3) Fixes: 945c904f956580616f0d71b13c63f525c184060c --- src/devices/nm-device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 0f27ae3b01..76f51c6fa0 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9905,6 +9905,8 @@ nm_device_activate_stage3_ip6_start (NMDevice *self) static void activate_stage3_ip_config_start (NMDevice *self) { + int ifindex; + _set_ip_state (self, AF_INET, IP_WAIT); _set_ip_state (self, AF_INET6, IP_WAIT); @@ -9914,7 +9916,8 @@ activate_stage3_ip_config_start (NMDevice *self) nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); /* Device should be up before we can do anything with it */ - if (!nm_platform_link_is_up (nm_device_get_platform (self), nm_device_get_ip_ifindex (self))) + if ( (ifindex = nm_device_get_ip_ifindex (self)) > 0 + && !nm_platform_link_is_up (nm_device_get_platform (self), ifindex)) _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); /* IPv4 */