From: Brian Norris Date: Sat, 28 Feb 2015 10:23:26 +0000 (-0800) Subject: UBI: fix out of bounds write X-Git-Tag: v3.4.109~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ef6369ce62c086c475891681e529f24b377241c;p=thirdparty%2Fkernel%2Fstable.git UBI: fix out of bounds write commit d74adbdb9abf0d2506a6c4afa534d894f28b763f upstream. If aeb->len >= vol->reserved_pebs, we should not be writing aeb into the PEB->LEB mapping. Caught by Coverity, CID #711212. Signed-off-by: Brian Norris Signed-off-by: Richard Weinberger [lizf: Backported to 3.4: adjust context] Signed-off-by: Zefan Li --- diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 2455d620d96b8..9abc0ea6702e8 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -1261,7 +1261,8 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) * during re-size. */ ubi_scan_move_to_list(sv, seb, &si->erase); - vol->eba_tbl[seb->lnum] = seb->pnum; + else + vol->eba_tbl[seb->lnum] = seb->pnum; } }