From: Miquel Raynal Date: Mon, 18 Dec 2017 07:26:28 +0000 (+0100) Subject: mtd: Fix mtd_check_oob_ops() X-Git-Tag: v4.15-rc5~21^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d82c3682168431d29ba1741d0cd5ef45c68bf8e0;p=thirdparty%2Fkernel%2Flinux.git mtd: Fix mtd_check_oob_ops() The mtd_check_oob_ops() helper verifies if the operation defined by the user is correct. Fix the check that verifies if the entire requested area exists. This check is too restrictive and will fail anytime the last data byte of the very last page is included in an operation. Fixes: 5cdd929da53d ("mtd: Add sanity checks in mtd_write/read_oob()") Signed-off-by: Miquel Raynal Acked-by: Boris Brezillon Signed-off-by: Richard Weinberger --- diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index f80e911b88438..73b6055774474 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -1114,7 +1114,7 @@ static int mtd_check_oob_ops(struct mtd_info *mtd, loff_t offs, if (!ops->oobbuf) ops->ooblen = 0; - if (offs < 0 || offs + ops->len >= mtd->size) + if (offs < 0 || offs + ops->len > mtd->size) return -EINVAL; if (ops->ooblen) {