[PATCH 8/8] efi: Avoid a memory leak in efi_bind_block() on error path
Simon Glass
sjg at chromium.org
Mon Dec 16 16:15:55 CET 2024
Hi Heinrich,
On Tue, 10 Dec 2024 at 01:15, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 09.12.24 17:28, Simon Glass wrote:
> > Free the memory used if an error occurs.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > Suggested-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> > ---
> >
> > lib/efi/efi_app_init.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi/efi_app_init.c b/lib/efi/efi_app_init.c
> > index cc91e1d74b8..fec3f348cfb 100644
> > --- a/lib/efi/efi_app_init.c
> > +++ b/lib/efi/efi_app_init.c
> > @@ -60,8 +60,10 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio,
> > plat->handle = handle;
> > plat->blkio = blkio;
> > plat->device_path = malloc(device_path_len);
> > - if (!plat->device_path)
> > + if (!plat->device_path) {
> > + free(plat);
>
> As of origin master origin/next (9dd0a9ecaa539ad) plat is a local
> variable and not a pointer. You cannot free it.
>
> If there is some prerequisite patch that is making plat a pointer, you
> should add this correction to that patch.
This patch is for sjg/master as the original series has not landed in
Tom's tree (yet).
>
> Best regards
>
> Heinrich
>
> > return log_msg_ret("path", -ENOMEM);
> > + }
> > memcpy(plat->device_path, device_path, device_path_len);
> > ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), "efi_media",
> > plat, ofnode_null(), &dev);
>
Regards,
Simon
More information about the U-Boot
mailing list