Skip to content

Commit

Permalink
mtg: docg3: potential divide by zero in doc_write_oob()
Browse files Browse the repository at this point in the history
If we set oobdelta to zero then we will either return -EINVAL or hit
a divide (modulus) by zero on the next line when we check
"(ooblen % oobdelta)".  It's better to just return -EINVAL here instead.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
Dan Carpenter authored and Artem Bityutskiy committed Dec 10, 2012
1 parent ecfe57b commit 6c810f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/devices/docg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
oobdelta = mtd->ecclayout->oobavail;
break;
default:
oobdelta = 0;
return -EINVAL;
}
if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % oobdelta) ||
(ofs % DOC_LAYOUT_PAGE_SIZE))
Expand Down

0 comments on commit 6c810f9

Please sign in to comment.