[PATCH] mtd: spi: Add missing free in sf_get_bootflow
Tudor Ambarus
tudor.ambarus at linaro.org
Tue Dec 9 11:16:33 CET 2025
On 12/9/25 11:56 AM, Francois Berder wrote:
> Free buf if spi_flash_read_dm fails.
>
> Signed-off-by: Francois Berder <fberder at outlook.fr>
> ---
> drivers/mtd/spi/sf_bootdev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/spi/sf_bootdev.c b/drivers/mtd/spi/sf_bootdev.c
> index 017a74a3016..720faf51a1f 100644
> --- a/drivers/mtd/spi/sf_bootdev.c
> +++ b/drivers/mtd/spi/sf_bootdev.c
> @@ -35,8 +35,10 @@ static int sf_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
>
> ret = spi_flash_read_dm(sf, env_get_hex("script_offset_f", 0),
> size, buf);
> - if (ret)
> + if (ret) {
> + free(buf);
> return log_msg_ret("cmd", -EINVAL);
> + }
can we use a devm alloc method to get rid of the extra free handling?
> bflow->state = BOOTFLOWST_MEDIA;
>
> ret = bootmeth_set_bootflow(bflow->method, bflow, buf, size);
More information about the U-Boot
mailing list