[PATCH 03/15] i.MX FCB: Fix error checking
Sascha Hauer
s.hauer at pengutronix.de
Mon May 17 11:54:12 PDT 2021
The return value of imx_bbu_firmware_fcb_start_page() is assigned to an
unsigned type which is then tested for an error (<0). Test against a
signed variable instead to let the error checking actually work.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/imx-bbu-nand-fcb.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 4e680a0a51..3b07d539ee 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -1263,16 +1263,17 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
free(fcb);
fcb = xzalloc(sizeof(*fcb));
- fcb->Firmware1_startingPage = imx_bbu_firmware_fcb_start_page(mtd, !used);
- if (fcb->Firmware1_startingPage < 0) {
- ret = fcb->Firmware1_startingPage;
+
+ ret = imx_bbu_firmware_fcb_start_page(mtd, !used);
+ if (ret < 0)
goto out;
- }
- fcb->Firmware2_startingPage = imx_bbu_firmware_fcb_start_page(mtd, used);
- if (fcb->Firmware2_startingPage < 0) {
- ret = fcb->Firmware2_startingPage;
+ fcb->Firmware1_startingPage = ret;
+
+ ret = imx_bbu_firmware_fcb_start_page(mtd, used);
+ if (ret < 0)
goto out;
- }
+ fcb->Firmware2_startingPage = ret;
+
fcb->PagesInFirmware1 = fw_size / mtd->writesize;
fcb->PagesInFirmware2 = fcb->PagesInFirmware1;
--
2.29.2
More information about the barebox
mailing list