• N
    hw/arm/realview.c: Fix memory leak in realview_init() · b1ab03af
    Nikita Belov 提交于
    Variable 'ram_lo' is allocated unconditionally, but used only in some cases.
    When it is unused pointer will be lost at function exit, resulting in a
    memory leak. Allocate memory for 'ram_lo' only if it is needed.
    
    Valgrind output:
    ==16879== 240 bytes in 1 blocks are definitely lost in loss record 6,033 of 7,018
    ==16879==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16879==    by 0x33D2CE: malloc_and_trace (vl.c:2804)
    ==16879==    by 0x509E610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
    ==16879==    by 0x288836: realview_init (realview.c:55)
    ==16879==    by 0x28988C: realview_pb_a8_init (realview.c:375)
    ==16879==    by 0x341426: main (vl.c:4413)
    Signed-off-by: NNikita Belov <zodiac@ispras.ru>
    Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
    b1ab03af
realview.c 13.6 KB