]> xenbits.xensource.com Git - xen.git/commit
libs/guest: Fix resource leaks in xc_core_arch_map_p2m_tree_rw()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Feb 2023 14:51:20 +0000 (14:51 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Feb 2023 15:51:23 +0000 (15:51 +0000)
commit1868d7f22660c8980bd0a7e53f044467e8b63bb5
treeb3fb6ec1b16c91f1b8959ab82c9a28605dfc14c4
parent35b3208a741f182ad95ad252944a82f4899f3816
libs/guest: Fix resource leaks in xc_core_arch_map_p2m_tree_rw()

Edwin, with the help of GCC's -fanalyzer, identified that p2m_frame_list_list
gets leaked.  What fanalyzer can't see is that the live_p2m_frame_list_list
and live_p2m_frame_list foreign mappings are leaked too.

Rework the logic so the out path is executed unconditionally, which cleans up
all the intermediate allocations/mappings appropriately.

Fixes: bd7a29c3d0b9 ("tools/libs/ctrl: fix xc_core_arch_map_p2m() to support linear p2m table")
Reported-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
tools/libs/guest/xg_core_x86.c