[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] drivers/xen/grant-table.c: Be sure of unsigned value never comparing with 0



In grow_gnttab_list(), 'i' is 'unsigned int', and 'nr_glist_frames' may
be 0 because 'nr_grant_frames' may be 0. So 'i' may never be less than
'nr_glist_frames' in failure processing, which cause infinite looping.

Signed-off-by: Chen Gang <gang.chen.5i5j@xxxxxxxxx>
---
 drivers/xen/grant-table.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index c254ae0..be07645 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -592,8 +592,8 @@ static int grow_gnttab_list(unsigned int more_frames)
        return 0;
 
 grow_nomem:
-       for ( ; i >= nr_glist_frames; i--)
-               free_page((unsigned long) gnttab_list[i]);
+       while (i > nr_glist_frames)
+               free_page((unsigned long) gnttab_list[--i]);
        return -ENOMEM;
 }
 
-- 
1.9.3

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.