public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: mikukkon@iki.fi
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bug in fs/afs/write.c function afs_write_back_from_locked_page()
Date: Thu, 10 May 2007 13:33:18 +0100	[thread overview]
Message-ID: <10764.1178800398@redhat.com> (raw)
In-Reply-To: <20070510115927.GB16409@srv1-m700-lanp.koti>


How about the attached instead?

David
---
AFS: Fix interminable loop in afs_write_back_from_locked_page()

From: Mika Kukkonen <mikukkon@miku.homelinux.net>

Following bug was uncovered by compiling with '-W' flag:

  CC [M]  fs/afs/write.o
fs/afs/write.c: In function ‘afs_write_back_from_locked_page’:
fs/afs/write.c:398: warning: comparison of unsigned expression >= 0 is always true

Loop variable 'n' is unsigned, so wraps around happily as far as I can
see. Trival fix attached (compile tested only).

Signed-Off-By: Mika Kukkonen <mikukkon@iki.fi>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/afs/write.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/afs/write.c b/fs/afs/write.c
index 67ae4db..c26d5e8 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -395,8 +395,10 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
 		if (n == 0)
 			goto no_more;
 		if (pages[0]->index != start) {
-			for (n--; n >= 0; n--)
-				put_page(pages[n]);
+			do {
+				put_page(pages[--n]);
+			} while (n > 0);
+			put_page(pages[0]);
 			goto no_more;
 		}
 

  reply	other threads:[~2007-05-10 12:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 11:59 [PATCH] Bug in fs/afs/write.c function afs_write_back_from_locked_page() Mika Kukkonen
2007-05-10 12:33 ` David Howells [this message]
2007-05-10 12:35   ` David Howells

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=10764.1178800398@redhat.com \
    --to=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikukkon@iki.fi \
    /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