From b92d1f55133b0ffe49df89e7aab67b8db7036fa5 Mon Sep 17 00:00:00 2001 From: Junaid Babu Date: Tue, 17 Dec 2019 13:56:26 +0900 Subject: [PATCH] Fix refCount check at releaseNetworkFor When releaseNetworkFor is called, refCount should be equal to 1 for network.stop() to be called. This is the same logic that is followed by WifiNetworkFactory also. In the current code, when refCount is 2 and releaseNetworkFor() is called, network.stop() will be executed and will stop Ethernet Bug: 146089778 Test: build and boot OK Change-Id: Ib7d1b488a2943364a8ba4a89eec5de4c33cf1d5a --- .../com/android/server/ethernet/EthernetNetworkFactory.java | 4 ++-- 1 file changed, 2 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 3cda13f330..11c991d408 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -120,11 +120,11 @@ public class EthernetNetworkFactory extends NetworkFactory { protected void releaseNetworkFor(NetworkRequest networkRequest) { NetworkInterfaceState network = networkForRequest(networkRequest); if (network == null) { - Log.e(TAG, "needNetworkFor, failed to get a network for " + networkRequest); + Log.e(TAG, "releaseNetworkFor, failed to get a network for " + networkRequest); return; } - if (--network.refCount == 1) { + if (--network.refCount == 0) { network.stop(); } }