From: Chen Gang <gang.chen.5i5j@gmail.com>
To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com,
david.vrabel@citrix.com
Cc: xen-devel@lists.xenproject.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
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 [thread overview]
Message-ID: <53FCAA04.40009@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2014-08-26 15:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 15:38 Chen Gang [this message]
2014-08-26 17:03 ` [PATCH] drivers/xen/grant-table.c: Be sure of unsigned value never comparing with 0 David Vrabel
2014-08-26 19:42 ` Chen Gang
2014-08-27 10:06 ` David Vrabel
2014-08-27 10:27 ` Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53FCAA04.40009@gmail.com \
--to=gang.chen.5i5j@gmail.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox