storage: Use storage_close() to free up resources on exit

Use storage_close() to free up the shadow buffers as well, to avoid any
lingering allocations.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson 2020-12-07 08:43:18 -08:00
parent bf5cb9faf2
commit 1cc12d3dc1

View File

@ -151,8 +151,10 @@ found:
void storage_close(struct rmtfd *rmtfd)
{
if (rmtfd->fd >= 0) {
close(rmtfd->fd);
rmtfd->fd = -1;
}
free(rmtfd->shadow_buf);
rmtfd->shadow_buf = NULL;
@ -189,10 +191,8 @@ void storage_exit(void)
{
int i;
for (i = 0; i < MAX_CALLERS; i++) {
if (rmtfds[i].fd >= 0)
close(rmtfds[i].fd);
}
for (i = 0; i < MAX_CALLERS; i++)
storage_close(&rmtfds[i]);
}
ssize_t storage_pread(const struct rmtfd *rmtfd, void *buf, size_t nbyte, off_t offset)