Skip to contentSkip to conversation

x86/mm: Fix infinite loop in get_spage_pages()

PATCH In review Andrew Cooper 4 participants 4 messages Jun 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Fix infinite loop in get_spage_pages()

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

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/mm.c +1 -1
index b20f37f..19f672d 100644
@@ -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;
         }
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by Konrad Rzeszutek Will on v1 1/1
#1 lore raw
Quoted 8 lines · Andrew Cooper

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

But I think Wei posted a similar one earlier?

Quoted 19 lines

---
CC: Jan Beulich <[email protected]>
---
xen/arch/x86/mm.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/mm.c +1 -1
index b20f37f..19f672d 100644
@@ -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;
Quoted 9 lines
        }
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Thanks!

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 6 lines · Andrew Cooper

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

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#3 lore raw
In reply to Andrew Cooper
Quoted 7 lines
Quoted 1 line
Quoted 1 line

Andrew Cooper <[email protected]> 06/26/17 1:59 PM >>>

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

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel