]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: rawnand: mxs_nand: Ensure err is set for error path
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 1 Aug 2025 09:54:06 +0000 (10:54 +0100)
committerMichael Trimarchi <michael@amarulasolutions.com>
Sun, 3 Aug 2025 08:22:04 +0000 (10:22 +0200)
In mxs_nand_init_ctrl there are a couple of error paths that do not set
err which could lead to the errors being silently ignored despite the
function not completing. Rather than just using if to detect these
errors use err to collect the error return value from the called
functions.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
drivers/mtd/nand/raw/mxs_nand.c

index ba67466069bde6cebbbbe8951457d0f77d38b944..fecf1f5ba91ed9fd891dd41ed8c10d1cc246694a 100644 (file)
@@ -1640,10 +1640,12 @@ int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info)
                nand->setup_data_interface = mxs_nand_setup_interface;
 
        /* first scan to find the device and get the page size */
-       if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL))
+       err = nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL);
+       if (err)
                goto err_free_buffers;
 
-       if (mxs_nand_setup_ecc(mtd))
+       err = mxs_nand_setup_ecc(mtd);
+       if (err)
                goto err_free_buffers;
 
        nand->ecc.read_page     = mxs_nand_ecc_read_page;