elf/cache.c: Fix resource leaks identified by static analyzers
commita85cdcdb35ed693d0e6eae63dfaca0cffae12765
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 18 May 2021 03:38:41 +0000 (18 09:08 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 18 May 2021 03:38:41 +0000 (18 09:08 +0530)
tree95203e67306085aee417918d5997b326ea55867e
parent2317101658488102f54d4c700fd2da839b6fec29
elf/cache.c: Fix resource leaks identified by static analyzers

A coverity run identified a number of resource leaks in cache.c.
There are a couple of simple memory leaks where a local allocation is
not freed before function return.  Then there is a mmap leak and a
file descriptor leak where a map is not unmapped in the error case and
a file descriptor remains open respectively.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
elf/cache.c