Skip to contentSkip to conversation

xen/ept: Correct double unmap_domain_page() on error path

PATCH In review Andrew Cooper 2 participants 2 messages Apr 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/ept: Correct double unmap_domain_page() on error path

c/s 3d90d6e6 "x86/EPT: split super pages upon mismatching memory types" accidentally introduced an error path where the epte domain page would be unmapped twice if splitting the superpage failed.

Only unmap the page if the loop is to be continued. When breaking from the loop, the page will be unmapped by the subsequent code.

Coverity-ID: 1203047

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
---
 xen/arch/x86/mm/p2m-ept.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/mm/p2m-ept.c +1 -1
index eeb95bb..f064f0b 100644
@@ -350,9 +350,9 @@ bool_t ept_handle_misconfig(uint64_t gpa)
                                              e.sa_p2mt == p2m_mmio_direct);
                 if ( unlikely(emt < 0) )
                 {
-                    unmap_domain_page(epte);
                     if ( ept_split_super_page(p2m, &e, level, level - 1) )
                     {
+                        unmap_domain_page(epte);
                         mfn = e.mfn;
                         continue;
                     }
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 16.04.14 at 13:37, <[email protected]> wrote:

c/s 3d90d6e6 "x86/EPT: split super pages upon mismatching memory types" accidentally introduced an error path where the epte domain page would be unmapped twice if splitting the superpage failed.

Only unmap the page if the loop is to be continued. When breaking from the loop, the page will be unmapped by the subsequent code.

Coverity-ID: 1203047

Quoted 13 lines
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -350,9 +350,9 @@ bool_t ept_handle_misconfig(uint64_t gpa)
                                              e.sa_p2mt == p2m_mmio_direct);
                 if ( unlikely(emt < 0) )
                 {
-                    unmap_domain_page(epte);
                     if ( ept_split_super_page(p2m, &e, level, level - 1) )
                     {
+                        unmap_domain_page(epte);
                         mfn = e.mfn;
                         continue;
                     }