Commit 997ebacd authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile: Plug memory leak in ramh_close()

No one was freeing RAMH structure itself, and thus ASAN reports e.g.:

==15935==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f29c89f1001 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x94001)
    #1 0x401da1 in zalloc include/wendelin/utils.h:65
    #2 0x408128 in shmfs_ramh_open bigfile/tests/../ram_shmfs.c:202
    #3 0x407611 in ramh_open bigfile/tests/../ram.c:81
    #4 0x402560 in fileh_open bigfile/tests/../virtmem.c:131
    #5 0x427ca1 in test_pagefault_savestate bigfile/tests/test_virtmem.c:1022
    #6 0x4281ba in main bigfile/tests/test_virtmem.c:1061
    #7 0x7f29c83b8b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

NOTE similar leak remains open in ram_close(), but it is a bit involved
to fix and the effort will be removed anyway after we switch to kernel
virtual memory manager. Besides ramh are opened and closed all the time
and ram only once.
parent e8c05a22
......@@ -65,6 +65,7 @@ void ramh_drop_memory(RAMH *ramh, pgoff_t ramh_pgoffset)
void ramh_close(RAMH *ramh)
{
/* NOTE ->close() should free ramh structure itself */
ramh->ramh_ops->close(ramh);
}
......
......@@ -165,7 +165,7 @@ static void shmfs_close(RAMH *ramh0)
ramh->ramh_fd = -1;
ramh->ramh_fpgsize = 0;
// TODO free(self) ?
free(ramh);
}
......
......@@ -125,7 +125,7 @@ void ramh_limited_close(RAMH *ramh0)
{
RAMHLimited *ramh = upcast(RAMHLimited *, ramh0);
ramh->backend->ramh_ops->close(ramh->backend);
// TODO free(self) ?
free(ramh);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment