[PATCH 3/3] mtd: rawnand: mxs_nand: Ensure err is set for error path
Michael Nazzareno Trimarchi
michael at amarulasolutions.com
Sun Aug 3 10:17:03 CEST 2025
Hi
On Fri, Aug 1, 2025 at 11:54 AM Andrew Goodbody <andrew.goodbody at linaro.org>
wrote:
> 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 at linaro.org>
> ---
> drivers/mtd/nand/raw/mxs_nand.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> 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;
>
>
Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>
> --
> 2.39.5
>
>
--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael at amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info at amarulasolutions.com
www.amarulasolutions.com
More information about the U-Boot
mailing list