xfs: fix unsigned underflow in xfs_free_eofblocks
authorKulikov Vasiliy <segooon@gmail.com>
Tue, 20 Jul 2010 07:54:28 +0000 (17:54 +1000)
committerAlex Elder <aelder@sgi.com>
Mon, 26 Jul 2010 18:16:50 +0000 (13:16 -0500)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_vnodeops.c

index 9865e11360170cf3b1bce49e8462cf4410d4e00e..3ac137dd531bb5481b5ec04ef085de3a6506878d 100644 (file)
@@ -589,9 +589,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);