Skip to contentSkip to conversation

logfs: signedness issue in mtd_find_last_sb()

PATCH New Dan Carpenter 1 participant 1 message Sep 10, 2010 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 logfs: signedness issue in mtd_find_last_sb()

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

---
This was found by a static checker and I have only compile tested it. Sorry about that.

fs/logfs/dev_mtd.c +2 -2
index a85d47d..99b3d4c 100644
@@ -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);