From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016AbaHZTnA (ORCPT ); Tue, 26 Aug 2014 15:43:00 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:37944 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639AbaHZTm7 (ORCPT ); Tue, 26 Aug 2014 15:42:59 -0400 Message-ID: <53FCE338.1050304@gmail.com> Date: Wed, 27 Aug 2014 03:42:48 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: David Vrabel CC: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, xen-devel@lists.xenproject.org, "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] drivers/xen/grant-table.c: Be sure of unsigned value never comparing with 0 References: <53FCAA04.40009@gmail.com> <53FCBDD2.8040208@citrix.com> In-Reply-To: <53FCBDD2.8040208@citrix.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/27/2014 01:03 AM, David Vrabel wrote: > On 26/08/14 16:38, Chen Gang wrote: >> 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. > > nr_grant_frames is at least 1. See gnttab_init(). > OK, thanks, that sounds reasonable to me, it is not a real wold bug, it is my fault. :-) >> --- 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]); > > while (i-- > nr_glist_frames) > ... > > Would have been better. > OK, thanks, that sounds reasonable to me. If necessary to send patch v2 (change comments and contents), please let me know, and I shall send. Thanks. -- Chen Gang Open share and attitude like air water and life which God blessed