From: Brian Norris Date: Sat, 28 Feb 2015 10:23:26 +0000 (-0800) Subject: UBI: fix out of bounds write X-Git-Tag: v3.18.14~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2ffa098d6f9d427269912e33beecb00c57d9460;p=thirdparty%2Fkernel%2Fstable.git UBI: fix out of bounds write [ Upstream commit d74adbdb9abf0d2506a6c4afa534d894f28b763f ] If aeb->len >= vol->reserved_pebs, we should not be writing aeb into the PEB->LEB mapping. Caught by Coverity, CID #711212. Cc: stable Signed-off-by: Brian Norris Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 2402d3b50171d..493f7b3dbc335 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1361,7 +1361,8 @@ int ubi_eba_init(struct ubi_device *ubi, struct ubi_attach_info *ai) * during re-size. */ ubi_move_aeb_to_list(av, aeb, &ai->erase); - vol->eba_tbl[aeb->lnum] = aeb->pnum; + else + vol->eba_tbl[aeb->lnum] = aeb->pnum; } }