From: Dan Carpenter Date: Thu, 29 Nov 2012 14:16:51 +0000 (+0300) Subject: mtg: docg3: potential divide by zero in doc_write_oob() X-Git-Tag: upstream/snapshot3+hdmi~6004^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c810f90140a3274181c4093d5dd4c88c6fff0b4;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git mtg: docg3: potential divide by zero in doc_write_oob() 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 Acked-by: Robert Jarzmik Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index d34d83b..8510ccb 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c @@ -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))