summaryrefslogtreecommitdiff
path: root/service-t/src
diff options
context:
space:
mode:
authorPatrick Rohr <prohr@google.com>2021-08-20 07:56:26 +0200
committerPatrick Rohr <prohr@google.com>2021-08-20 09:36:00 +0200
commit4cf6809d7583c134d38f2aa5883abdbac06b32e9 (patch)
tree461805f84ed91e11dd817acd4ed40dbeb221446a /service-t/src
parent698b59510f6286723096742ce46cea9586fdd052 (diff)
prevent nullptr dereference when calling unwanted
When the EthernetNetworkAgent has already been stopped, a call to unwanted will cause a crash due to a nullptr derefernce. Bug: 197279734 Test: atest EthernetNetworkFactoryTest Change-Id: Ice39c603bdd3e3139aa8ece7fb897bf7b567e74b
Diffstat (limited to 'service-t/src')
-rw-r--r--service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
index 32dbd7e0b6..cd086e721f 100644
--- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -506,12 +506,15 @@ public class EthernetNetworkFactory extends NetworkFactory {
mNetworkFactory.getProvider(), new EthernetNetworkAgent.Callbacks() {
@Override
public void onNetworkUnwanted() {
+ // if mNetworkAgent is null, we have already called stop.
+ if (mNetworkAgent == null) return;
+
if (this == mNetworkAgent.getCallbacks()) {
stop();
- } else if (mNetworkAgent != null) {
+ } else {
Log.d(TAG, "Ignoring unwanted as we have a more modern " +
"instance");
- } // Otherwise, we've already called stop.
+ }
}
});
mNetworkAgent.register();