public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/8] xfs: fix unsigned underflow
@ 2010-07-15 18:46 Kulikov Vasiliy
  2010-07-15 21:21 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Kulikov Vasiliy @ 2010-07-15 18:46 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Alex Elder, xfs-masters, Christoph Hellwig, Dave Chinner,
	Felix Blyakher, xfs, linux-kernel

map_len is unsigned. Checking map_len <= 0 is buggy when it should be
below zero. So, check exact expression instead of map_len.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 fs/xfs/xfs_vnodeops.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 65e0879..66d585c 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -591,9 +591,9 @@ xfs_free_eofblocks(
 	 */
 	end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size));
 	last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
-	map_len = last_fsb - end_fsb;
-	if (map_len <= 0)
+	if (last_fsb <= end_fsb)
 		return 0;
+	map_len = last_fsb - end_fsb;
 
 	nimaps = 1;
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-20 23:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 18:46 [PATCH 6/8] xfs: fix unsigned underflow Kulikov Vasiliy
2010-07-15 21:21 ` Christoph Hellwig
2010-07-20 19:35   ` Alex Elder
2010-07-20 20:21     ` Vasiliy Kulikov
2010-07-20 23:12     ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox