[PATCH 1/3] mtd: nand: pxa3xx: Free memory on error

Michael Nazzareno Trimarchi michael at amarulasolutions.com
Sun Aug 3 10:17:43 CEST 2025


Hi

On Fri, Aug 1, 2025 at 12:39 PM Andrew Goodbody <andrew.goodbody at linaro.org>
wrote:

> In pxa3xx_nand_probe_dt if the function detects an error after
> allocating memory that memory is not freed before exit. Add the
> appropriate free.
>
> This issue was found by Smatch.
>
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>  drivers/mtd/nand/raw/pxa3xx_nand.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c
> b/drivers/mtd/nand/raw/pxa3xx_nand.c
> index b78b4e60238..7bf54fa4654 100644
> --- a/drivers/mtd/nand/raw/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/raw/pxa3xx_nand.c
> @@ -1765,6 +1765,7 @@ static int pxa3xx_nand_probe_dt(struct udevice *dev,
> struct pxa3xx_nand_info *in
>         pdata->num_cs = dev_read_u32_default(dev, "num-cs", 1);
>         if (pdata->num_cs != 1) {
>                 pr_err("pxa3xx driver supports single CS only\n");
> +               kfree(pdata);
>                 return -EINVAL;
>         }
>

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