Fix resource leaks

Change-Id: I3a201cfd924e467d605351782bd06874c2af725e
Merge "Fix resource leaks" into cm-11.0
Merge remote branch 'cm/cm-11.0' into cm-11.0