From: Chen Gang Subject: [PATCH] drivers/xen/grant-table.c: Be sure of unsigned value never comparing with 0 Date: Tue, 26 Aug 2014 23:38:44 +0800 Message-ID: <53FCAA04.40009__41280.4507803687$1409067949$gmane$org@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XMIpc-00005x-EC for xen-devel@lists.xenproject.org; Tue, 26 Aug 2014 15:38:48 +0000 Received: by mail-pa0-f53.google.com with SMTP id rd3so23161094pab.26 for ; Tue, 26 Aug 2014 08:38:45 -0700 (PDT) List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, david.vrabel@citrix.com Cc: xen-devel@lists.xenproject.org, "linux-kernel@vger.kernel.org" List-Id: xen-devel@lists.xenproject.org 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 --- 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