logd: serialize accesses to stats helpers

(cherry pick from commit ed777e9eece54bf899f1a77a83f8b702970de686)

Quick low-risk to resolve possible hash table corruption.
Resolved an unlikely path memory leak.

ToDo: replace lock with nested lock so no lock
      helpers are required.

Bug: 22068332
Change-Id: I303ab06608502c7d61d42f111a9c43366f184d0c
4 files changed