On 13.06.2023 18:03, Anthony PERARD wrote: > On Mon, Jun 12, 2023 at 01:46:40PM +0200, Jan Beulich wrote: >> The function returns immediately after the enclosing if(). >> >> Coverity ID: 1532314 >> Fixes: bd7a29c3d0b9 ("tools/libs/ctrl: fix xc_core_arch_map_p2m() to support >> linear p2m table") >> Signed-off-by: Jan Beulich <jbeul...@suse.com> >> >> --- a/tools/libs/guest/xg_core_x86.c >> +++ b/tools/libs/guest/xg_core_x86.c >> @@ -210,7 +210,6 @@ xc_core_arch_map_p2m_list_rw(xc_interfac >> } >> >> munmap(ptes, n_pages * PAGE_SIZE); >> - ptes = NULL; >> off = p2m_vaddr & ((mask >> shift) << shift); >> } > > Do we have to remove this assignment? What if someone adds code later > and reuse the content of the variable `ptes`? Or what if someone adds > codes after the loop, and handle an error with `goto out`, we would have > a double-munmap().
Imo it would be at that time when the assignment wants (re)adding. I fully agree with the tool, and I expect Misra (if it was applied to the tool stack as well) would demand the very same change. Jan