From decca62338a0b657c7b4932170d513b6375815f6 Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Wed, 14 Apr 2021 13:01:54 -0700 Subject: [PATCH] Add null pointer check for mConfig in onSessionLost Bug: 185291618 Test: atest VpnTest Test: atest Ikev2VpnTest Change-Id: I492e72b5cc0d4ef9d36910af2d64b0c7eb34d202 --- .../com/android/server/connectivity/Vpn.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 57c25f6a04a60..d6f0967ad0be0 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -2696,19 +2696,21 @@ public class Vpn { // prevent the NetworkManagementEventObserver from killing this VPN based on the // interface going down (which we expect). mInterface = null; - mConfig.interfaze = null; + if (mConfig != null) { + mConfig.interfaze = null; - // Set as unroutable to prevent traffic leaking while the interface is down. - if (mConfig != null && mConfig.routes != null) { - final List oldRoutes = new ArrayList<>(mConfig.routes); + // Set as unroutable to prevent traffic leaking while the interface is down. + if (mConfig.routes != null) { + final List oldRoutes = new ArrayList<>(mConfig.routes); - mConfig.routes.clear(); - for (final RouteInfo route : oldRoutes) { - mConfig.routes.add(new RouteInfo(route.getDestination(), null /*gateway*/, - null /*iface*/, RTN_UNREACHABLE)); - } - if (mNetworkAgent != null) { - mNetworkAgent.sendLinkProperties(makeLinkProperties()); + mConfig.routes.clear(); + for (final RouteInfo route : oldRoutes) { + mConfig.routes.add(new RouteInfo(route.getDestination(), + null /*gateway*/, null /*iface*/, RTN_UNREACHABLE)); + } + if (mNetworkAgent != null) { + mNetworkAgent.sendLinkProperties(makeLinkProperties()); + } } } }