x86/p2m: fix p2m_add_foreign error path
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 4 Jan 2021 09:03:23 +0000 (10:03 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 4 Jan 2021 10:41:59 +0000 (10:41 +0000)
commit62dde2c1eff6d4e5d45883b78bdae5447e7d2d9c
tree6fe980cd7fc8fab09545c3a814a7e00a3277af65
parent1516ecd6f55fe3608f374f4f2548491472d1c9a1
x86/p2m: fix p2m_add_foreign error path

One of the error paths in p2m_add_foreign could call put_page with a
NULL page, thus triggering a fault.

Split the checks into two different if statements, so the appropriate
error path can be taken.

Fixes: 173ae325026bd ('x86/p2m: tidy p2m_add_foreign() a little')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm/p2m.c