.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2012 Linutronix GmbH |
---|
3 | 4 | * Copyright (c) 2014 sigma star gmbh |
---|
4 | 5 | * Author: Richard Weinberger <richard@nod.at> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; version 2. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
---|
13 | | - * the GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/crc32.h> |
---|
.. | .. |
---|
477 | 468 | if (err == UBI_IO_FF_BITFLIPS) |
---|
478 | 469 | scrub = 1; |
---|
479 | 470 | |
---|
480 | | - add_aeb(ai, free, pnum, ec, scrub); |
---|
| 471 | + ret = add_aeb(ai, free, pnum, ec, scrub); |
---|
| 472 | + if (ret) |
---|
| 473 | + goto out; |
---|
481 | 474 | continue; |
---|
482 | 475 | } else if (err == 0 || err == UBI_IO_BITFLIPS) { |
---|
483 | 476 | dbg_bld("Found non empty PEB:%i in pool", pnum); |
---|
.. | .. |
---|
647 | 640 | if (fm_pos >= fm_size) |
---|
648 | 641 | goto fail_bad; |
---|
649 | 642 | |
---|
650 | | - add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), |
---|
651 | | - be32_to_cpu(fmec->ec), 0); |
---|
| 643 | + ret = add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), |
---|
| 644 | + be32_to_cpu(fmec->ec), 0); |
---|
| 645 | + if (ret) |
---|
| 646 | + goto fail; |
---|
652 | 647 | } |
---|
653 | 648 | |
---|
654 | 649 | /* read EC values from used list */ |
---|
.. | .. |
---|
658 | 653 | if (fm_pos >= fm_size) |
---|
659 | 654 | goto fail_bad; |
---|
660 | 655 | |
---|
661 | | - add_aeb(ai, &used, be32_to_cpu(fmec->pnum), |
---|
662 | | - be32_to_cpu(fmec->ec), 0); |
---|
| 656 | + ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum), |
---|
| 657 | + be32_to_cpu(fmec->ec), 0); |
---|
| 658 | + if (ret) |
---|
| 659 | + goto fail; |
---|
663 | 660 | } |
---|
664 | 661 | |
---|
665 | 662 | /* read EC values from scrub list */ |
---|
.. | .. |
---|
669 | 666 | if (fm_pos >= fm_size) |
---|
670 | 667 | goto fail_bad; |
---|
671 | 668 | |
---|
672 | | - add_aeb(ai, &used, be32_to_cpu(fmec->pnum), |
---|
673 | | - be32_to_cpu(fmec->ec), 1); |
---|
| 669 | + ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum), |
---|
| 670 | + be32_to_cpu(fmec->ec), 1); |
---|
| 671 | + if (ret) |
---|
| 672 | + goto fail; |
---|
674 | 673 | } |
---|
675 | 674 | |
---|
676 | 675 | /* read EC values from erase list */ |
---|
.. | .. |
---|
680 | 679 | if (fm_pos >= fm_size) |
---|
681 | 680 | goto fail_bad; |
---|
682 | 681 | |
---|
683 | | - add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), |
---|
684 | | - be32_to_cpu(fmec->ec), 1); |
---|
| 682 | + ret = add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), |
---|
| 683 | + be32_to_cpu(fmec->ec), 1); |
---|
| 684 | + if (ret) |
---|
| 685 | + goto fail; |
---|
685 | 686 | } |
---|
686 | 687 | |
---|
687 | 688 | ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); |
---|