From: Andrew Goodbody Date: Fri, 1 Aug 2025 09:54:06 +0000 (+0100) Subject: mtd: rawnand: mxs_nand: Ensure err is set for error path X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27242462167f678cb6ec78fa8c97f25c9557cb1e;p=thirdparty%2Fu-boot.git mtd: rawnand: mxs_nand: Ensure err is set for error path 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 Reviewed-by: Michael Trimarchi --- diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c index ba67466069b..fecf1f5ba91 100644 --- a/drivers/mtd/nand/raw/mxs_nand.c +++ b/drivers/mtd/nand/raw/mxs_nand.c @@ -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;