All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v15 4/4] efi: Rename bootefi_test_finish() to bootefi_run_finish()
Date: Sun, 25 Nov 2018 06:30:32 -0700	[thread overview]
Message-ID: <CAPnjgZ3bHCDkWER4-bV=-xBQ7zjw3Si2=hskt81VrkBfoHo5ZQ@mail.gmail.com> (raw)
In-Reply-To: <50ac8a0f-388d-edaf-611f-95bc67643092@suse.de>

Hi Alex,

On Sun, 25 Nov 2018 at 06:27, Alexander Graf <agraf@suse.de> wrote:
>
>
>
> On 25.11.18 13:53, Simon Glass wrote:
> > Hi Alex,
> >
> > On Sat, 24 Nov 2018 at 14:26, Alexander Graf <agraf@suse.de> wrote:
> >>
> >>
> >>
> >> On 22.11.18 21:46, Simon Glass wrote:
> >>> This function can be used from do_bootefi_exec() so that we use mostly the
> >>> same code for a normal EFI application and an EFI test.
> >>>
> >>> Rename the function and use it in both places.
> >>>
> >>> Signed-off-by: Simon Glass <sjg@chromium.org>
> >>> ---
> >>>
> >>> Changes in v15:
> >>> - Add a comment about a leaked device path
> >>>
> >>> Changes in v14:
> >>> - Go back to the horrible long variable names
> >>> - Hopefully correct error paths in do_bootefi_exec()
> >>>
> >>> Changes in v13:
> >>> - Drop 'efi_loader: Drop setup_ok' as we have an existing patch for that
> >>> - Drop patches previously applied
> >>>
> >>> Changes in v12: None
> >>> Changes in v11:
> >>> - Drop patches previously applied
> >>>
> >>> Changes in v9: None
> >>> Changes in v7:
> >>> - Drop patch "efi: Init the 'rows' and 'cols' variables"
> >>> - Drop patches previous applied
> >>>
> >>> Changes in v5:
> >>> - Rebase to master
> >>>
> >>> Changes in v4:
> >>> - Rebase to master
> >>>
> >>> Changes in v3:
> >>> - Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
> >>>
> >>>  cmd/bootefi.c | 46 ++++++++++++++++++++++++----------------------
> >>>  1 file changed, 24 insertions(+), 22 deletions(-)
> >>>
> >>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> >>> index 0ca84ff7168..5831c991a8e 100644
> >>> --- a/cmd/bootefi.c
> >>> +++ b/cmd/bootefi.c
> >>> @@ -346,6 +346,20 @@ static efi_status_t bootefi_run_prepare(const char *load_options_path,
> >>>       return 0;
> >>>  }
> >>>
> >>> +/**
> >>> + * bootefi_run_finish() - finish up after running an EFI test
> >>> + *
> >>> + * @loaded_image_info: Pointer to a struct which holds the loaded image info
> >>> + * @image_objj: Pointer to a struct which holds the loaded image object
> >>> + */
> >>> +static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj,
> >>> +                            struct efi_loaded_image *loaded_image_info)
> >>> +{
> >>> +     efi_restore_gd();
> >>> +     free(loaded_image_info->load_options);
> >>> +     efi_delete_handle(&image_obj->header);
> >>> +}
> >>> +
> >>>  /**
> >>>   * do_bootefi_exec() - execute EFI binary
> >>>   *
> >>> @@ -386,11 +400,11 @@ static efi_status_t do_bootefi_exec(void *efi,
> >>>                */
> >>>               ret = efi_create_handle(&mem_handle);
> >>>               if (ret != EFI_SUCCESS)
> >>> -                     goto exit;
> >>> +                     return ret; /* TODO: leaks device_path */
> >>>               ret = efi_add_protocol(mem_handle, &efi_guid_device_path,
> >>>                                      device_path);
> >>>               if (ret != EFI_SUCCESS)
> >>> -                     goto exit;
> >>> +                     goto err_add_protocol;
> >>>       } else {
> >>>               assert(device_path && image_path);
> >>>       }
> >>> @@ -398,13 +412,13 @@ static efi_status_t do_bootefi_exec(void *efi,
> >>>       ret = bootefi_run_prepare("bootargs", device_path, image_path,
> >>>                                 &image_obj, &loaded_image_info);
> >>>       if (ret)
> >>> -             return ret;
> >>> +             goto err_prepare;
> >>>
> >>>       /* Load the EFI payload */
> >>>       entry = efi_load_pe(image_obj, efi, loaded_image_info);
> >>>       if (!entry) {
> >>>               ret = EFI_LOAD_ERROR;
> >>> -             goto exit;
> >>> +             goto err_prepare;
> >>>       }
> >>>
> >>>       if (memdp) {
> >>> @@ -424,7 +438,7 @@ static efi_status_t do_bootefi_exec(void *efi,
> >>>
> >>>       if (setjmp(&image_obj->exit_jmp)) {
> >>>               ret = image_obj->exit_status;
> >>> -             goto exit;
> >>> +             goto err_prepare;
> >>>       }
> >>>
> >>>  #ifdef CONFIG_ARM64
> >>> @@ -462,10 +476,11 @@ static efi_status_t do_bootefi_exec(void *efi,
> >>>
> >>>       ret = efi_do_enter(&image_obj->header, &systab, entry);
> >>>
> >>> -exit:
> >>> +err_prepare:
> >>>       /* image has returned, loaded-image obj goes *poof*: */
> >>> -     if (image_obj)
> >>> -             efi_delete_handle(&image_obj->header);
> >>> +     bootefi_run_finish(image_obj, loaded_image_info);
> >>
> >> So here we now free loaded_image_info->load_options which we didn't do
> >> before. That means the patch does change behavior.
> >>
> >> I think the change is correct though. For the sake of bisectability, I'd
> >> prefer if you could add a tiny patch before this patch that just adds
> >> the free(loaded_image_info->load_options) in this spot. We can then have
> >> this refactoring really be neutral as to behavior.
> >
> > I agree, it worries me that we are fixing up complex code in a refactor.
> >
> > Can you just use v14?
>
> v14 has the same problem, so unfortunately not :).

Ah yes. Oh dear. I will have another go.

Regards,
Simon

      reply	other threads:[~2018-11-25 13:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 20:46 [U-Boot] [PATCH v15 0/4] efi_loader: Code refactoring and improvement Simon Glass
2018-11-22 20:46 ` [U-Boot] [PATCH v15 1/4] sandbox: smbios: Update to support sandbox Simon Glass
2018-11-24 21:27   ` Alexander Graf
2018-11-25 13:28   ` [U-Boot] [U-Boot, v15, " Alexander Graf
2018-11-22 20:46 ` [U-Boot] [PATCH v15 2/4] efi: Split out test init/uninit into functions Simon Glass
2018-11-23 23:23   ` Heinrich Schuchardt
2018-11-24 18:49     ` Simon Glass
2018-11-22 20:46 ` [U-Boot] [PATCH v15 3/4] efi: Create a function to set up for running EFI code Simon Glass
2018-11-22 20:46 ` [U-Boot] [PATCH v15 4/4] efi: Rename bootefi_test_finish() to bootefi_run_finish() Simon Glass
2018-11-24 21:26   ` Alexander Graf
2018-11-25 12:53     ` Simon Glass
2018-11-25 13:27       ` Alexander Graf
2018-11-25 13:30         ` Simon Glass [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPnjgZ3bHCDkWER4-bV=-xBQ7zjw3Si2=hskt81VrkBfoHo5ZQ@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.