Fix thread race caused double free issue.
am: 5754b41c20

Change-Id: Ic9dd6e9c6d216753d997da99158816682d5464d1