From 602247e8e304e936b4e1a5e6e67533e3b9f26abb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 8 Nov 2016 09:48:27 +0100 Subject: [PATCH] ip-tunnel: avoid crash on missing NMPlatformLnkIp6Tnl lnk part You cannot assume that we are always able to lookup a corresponding lnk object. In fact, there is no guarantee that link->ifindex still exists in the platform cache at all. --- src/devices/nm-device-ip-tunnel.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 8732ddf9b5..ee3725434e 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -557,12 +557,13 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link) return NM_IP_TUNNEL_MODE_GRE; case NM_LINK_TYPE_IP6TNL: lnk = nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, link->ifindex, NULL); - if (lnk->proto == IPPROTO_IPIP) - return NM_IP_TUNNEL_MODE_IPIP6; - else if (lnk->proto == IPPROTO_IPV6) - return NM_IP_TUNNEL_MODE_IP6IP6; - else - return NM_IP_TUNNEL_MODE_UNKNOWN; + if (lnk) { + if (lnk->proto == IPPROTO_IPIP) + return NM_IP_TUNNEL_MODE_IPIP6; + if (lnk->proto == IPPROTO_IPV6) + return NM_IP_TUNNEL_MODE_IP6IP6; + } + return NM_IP_TUNNEL_MODE_UNKNOWN; case NM_LINK_TYPE_IPIP: return NM_IP_TUNNEL_MODE_IPIP; case NM_LINK_TYPE_SIT: