Fix some potentially unreleased memory, null value checks, files not
closed, and other such issues reported by codeql
Change-Id: Ia679aff97a773a642d8c8cbadeae30955554a62e
Signed-off-by: Kent Russell <kent.russell@amd.com>
[ROCm/ROCR-Runtime commit: d64e33520f]