提交 6c810f90 编写于 作者: D Dan Carpenter 提交者: Artem Bityutskiy

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: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NRobert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
上级 ecfe57b7
...@@ -1440,7 +1440,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, ...@@ -1440,7 +1440,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
oobdelta = mtd->ecclayout->oobavail; oobdelta = mtd->ecclayout->oobavail;
break; break;
default: default:
oobdelta = 0; return -EINVAL;
} }
if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % oobdelta) || if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % oobdelta) ||
(ofs % DOC_LAYOUT_PAGE_SIZE)) (ofs % DOC_LAYOUT_PAGE_SIZE))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册