hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mtd/ubi/fastmap.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2012 Linutronix GmbH
34 * Copyright (c) 2014 sigma star gmbh
45 * 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
- *
156 */
167
178 #include <linux/crc32.h>
....@@ -477,7 +468,9 @@
477468 if (err == UBI_IO_FF_BITFLIPS)
478469 scrub = 1;
479470
480
- add_aeb(ai, free, pnum, ec, scrub);
471
+ ret = add_aeb(ai, free, pnum, ec, scrub);
472
+ if (ret)
473
+ goto out;
481474 continue;
482475 } else if (err == 0 || err == UBI_IO_BITFLIPS) {
483476 dbg_bld("Found non empty PEB:%i in pool", pnum);
....@@ -647,8 +640,10 @@
647640 if (fm_pos >= fm_size)
648641 goto fail_bad;
649642
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;
652647 }
653648
654649 /* read EC values from used list */
....@@ -658,8 +653,10 @@
658653 if (fm_pos >= fm_size)
659654 goto fail_bad;
660655
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;
663660 }
664661
665662 /* read EC values from scrub list */
....@@ -669,8 +666,10 @@
669666 if (fm_pos >= fm_size)
670667 goto fail_bad;
671668
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;
674673 }
675674
676675 /* read EC values from erase list */
....@@ -680,8 +679,10 @@
680679 if (fm_pos >= fm_size)
681680 goto fail_bad;
682681
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;
685686 }
686687
687688 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);