Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 5224f00b authored by Hugo Benichi's avatar Hugo Benichi Committed by Lorenzo Colitti
Browse files

Fix unsafe concurrent access in LegacyTypeTracker

This patch adds synchronization inside LegacyTypeTracker so that
getNetworkForType() can safely run concurrently with remove().

Without synchronization if remove() removes the last network for a
given type while getNetworkForType() runs for the same type, it is
possible that getNetworkForType tries to access the head of an empty
list, resulting in a runtime exception.

This issue was found by zoran.jovanovic@sonymobile.com who proposed a
fix in AOSP (Change-Id: Ia963662edb9d643790e8d9439e4dbdcac4c2187b).

This patch differs from the fix proposed by the bug reporter and tries
instead to do the minimum amount of locking to make getNetworkForType
safe.

Bug: 29030387

(cherry picked from commit 78caa258)

Change-Id: I915aac527fc8828b32bf35fee870add2dfb11d8d
parent 9a3fbe11
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment