mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 22:54:01 +00:00
ubi: fastmap: Return error code if memory allocation fails in add_aeb()
commitc3c07fc25f
upstream. Abort fastmap scanning and return error code if memory allocation fails in add_aeb(). Otherwise ubi will get wrong peb statistics information after scanning. Fixes:dbb7d2a88d
("UBI: Add fastmap core") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0c1a26c3d3
commit
32a76a5574
1 changed files with 19 additions and 9 deletions
|
@ -468,7 +468,9 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
|
||||||
if (err == UBI_IO_FF_BITFLIPS)
|
if (err == UBI_IO_FF_BITFLIPS)
|
||||||
scrub = 1;
|
scrub = 1;
|
||||||
|
|
||||||
add_aeb(ai, free, pnum, ec, scrub);
|
ret = add_aeb(ai, free, pnum, ec, scrub);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
continue;
|
continue;
|
||||||
} else if (err == 0 || err == UBI_IO_BITFLIPS) {
|
} else if (err == 0 || err == UBI_IO_BITFLIPS) {
|
||||||
dbg_bld("Found non empty PEB:%i in pool", pnum);
|
dbg_bld("Found non empty PEB:%i in pool", pnum);
|
||||||
|
@ -638,8 +640,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
|
||||||
if (fm_pos >= fm_size)
|
if (fm_pos >= fm_size)
|
||||||
goto fail_bad;
|
goto fail_bad;
|
||||||
|
|
||||||
add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum),
|
ret = add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum),
|
||||||
be32_to_cpu(fmec->ec), 0);
|
be32_to_cpu(fmec->ec), 0);
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read EC values from used list */
|
/* read EC values from used list */
|
||||||
|
@ -649,8 +653,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
|
||||||
if (fm_pos >= fm_size)
|
if (fm_pos >= fm_size)
|
||||||
goto fail_bad;
|
goto fail_bad;
|
||||||
|
|
||||||
add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
|
ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
|
||||||
be32_to_cpu(fmec->ec), 0);
|
be32_to_cpu(fmec->ec), 0);
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read EC values from scrub list */
|
/* read EC values from scrub list */
|
||||||
|
@ -660,8 +666,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
|
||||||
if (fm_pos >= fm_size)
|
if (fm_pos >= fm_size)
|
||||||
goto fail_bad;
|
goto fail_bad;
|
||||||
|
|
||||||
add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
|
ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
|
||||||
be32_to_cpu(fmec->ec), 1);
|
be32_to_cpu(fmec->ec), 1);
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read EC values from erase list */
|
/* read EC values from erase list */
|
||||||
|
@ -671,8 +679,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
|
||||||
if (fm_pos >= fm_size)
|
if (fm_pos >= fm_size)
|
||||||
goto fail_bad;
|
goto fail_bad;
|
||||||
|
|
||||||
add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum),
|
ret = add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum),
|
||||||
be32_to_cpu(fmec->ec), 1);
|
be32_to_cpu(fmec->ec), 1);
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
|
ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
|
||||||
|
|
Loading…
Reference in a new issue