Commit 6c810f90140a3274181c4093d5dd4c88c6fff0b4

Authored by Dan Carpenter
Committed by Artem Bityutskiy
1 parent ecfe57b796

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 <dan.carpenter@oracle.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/mtd/devices/docg3.c
... ... @@ -1440,7 +1440,7 @@
1440 1440 oobdelta = mtd->ecclayout->oobavail;
1441 1441 break;
1442 1442 default:
1443   - oobdelta = 0;
  1443 + return -EINVAL;
1444 1444 }
1445 1445 if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % oobdelta) ||
1446 1446 (ofs % DOC_LAYOUT_PAGE_SIZE))