diff mbox

x86/mm: Fix infinite loop in get_spage_pages()

Message ID 1498478342-26517-1-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper June 26, 2017, 11:59 a.m. UTC
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>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Konrad Rzeszutek Wilk June 26, 2017, 12:09 p.m. UTC | #1
On June 26, 2017 7:59:02 AM EDT, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>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>

But I think Wei posted a similar one earlier?
>---
>CC: Jan Beulich <JBeulich@suse.com>
>---
> xen/arch/x86/mm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
>index b20f37f..19f672d 100644
>--- a/xen/arch/x86/mm.c
>+++ b/xen/arch/x86/mm.c
>@@ -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;
>         }
>-- 
>2.1.4
>
>
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xen.org
>https://lists.xen.org/xen-devel


Thanks!
Wei Liu June 26, 2017, 1:26 p.m. UTC | #2
On Mon, Jun 26, 2017 at 12:59:02PM +0100, Andrew Cooper wrote:
> 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: Wei Liu <wei.liu2@citrix.com>
Jan Beulich June 26, 2017, 8:36 p.m. UTC | #3
>>> Andrew Cooper <andrew.cooper3@citrix.com> 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
>Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox

Patch

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index b20f37f..19f672d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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;
         }