diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-11-29 18:16:51 +0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-12-10 17:28:49 +0400 |
commit | 6c810f90140a3274181c4093d5dd4c88c6fff0b4 (patch) | |
tree | 6e9ee0717e00b69bd52474789bc2ff38cf185912 /drivers | |
parent | ecfe57b796d4ccec7ea53783ca18a0ad48ad880b (diff) | |
download | linux-6c810f90140a3274181c4093d5dd4c88c6fff0b4.tar.xz |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/devices/docg3.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index d34d83b8f9c2..8510ccb9c6f0 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)) |