[patch] logfs: signedness issue in mtd_find_last_sb()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"*ofs" is unsigned here so it's never less than zero.

Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
---
This was found by a static checker and I have only compile tested it.
Sorry about that.

diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c
index a85d47d..99b3d4c 100644
--- a/fs/logfs/dev_mtd.c
+++ b/fs/logfs/dev_mtd.c
@@ -175,9 +175,9 @@ static struct page *mtd_find_last_sb(struct super_block *sb, u64 *ofs)
 
 	*ofs = mtd->size - mtd->erasesize;
 	while (mtd->block_isbad(mtd, *ofs)) {
-		*ofs -= mtd->erasesize;
-		if (*ofs <= 0)
+		if (*ofs <= mtd->erasesize)
 			return NULL;
+		*ofs -= mtd->erasesize;
 	}
 	*ofs = *ofs + mtd->erasesize - 0x1000;
 	BUG_ON(*ofs & ~PAGE_MASK);
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux