x86/mm: Fix infinite loop in get_spage_pages()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Jun 2017 11:58:25 +0000 (12:58 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Jun 2017 13:32:46 +0000 (14:32 +0100)
c/s 2b8eb37 switched int i to being unsigned, but the undo logic on failure
relied in i being signed.  As i being unsigned in still preforable, adjust the
undo logic to work with an unsigned i.

Coverity-ID: 1413017
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Will <konrad.wilk@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/mm.c

index b20f37f253cda46a2668238fe06143e606419ba1..19f672d880c8321f4992a49897448025699a129b 100644 (file)
@@ -2687,7 +2687,7 @@ static int get_spage_pages(struct page_info *page, struct domain *d)
     {
         if ( !get_page_and_type(page, d, PGT_writable_page) )
         {
-            while ( --i >= 0 )
+            while ( i-- > 0 )
                 put_page_and_type(--page);
             return 0;
         }