Re: [git:media_stage/master] media: atomisp_gmin_platform: stop abusing efivar API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mauro,

On Fri, 8 Jul 2022 at 18:50, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx> wrote:
>
> This is an automatic generated email to let you know that the following patch were queued:
>
> Subject: media: atomisp_gmin_platform: stop abusing efivar API
> Author:  Ard Biesheuvel <ardb@xxxxxxxxxx>
> Date:    Mon Jun 20 11:08:19 2022 +0100
>

This patch has been queued up in the efi/next tree, and has also
appeared in linux-next, since 20 June, more or less.


> As the code comment already suggests, using the efivar API in this way
> is not how it is intended, and so let's switch to the right one, which
> is simply to call efi.get_variable() directly after checking whether or
> not the GetVariable() runtime service is supported.
>
> Link: https://lore.kernel.org/linux-media/20220620100819.1682995-1-ardb@xxxxxxxxxx
> Cc: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
>
>  .../media/atomisp/pci/atomisp_gmin_platform.c      | 27 +++++-----------------
>  1 file changed, 6 insertions(+), 21 deletions(-)
>
> ---
>
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> index 7e47db82de07..bf527b366ab3 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> @@ -1284,7 +1284,7 @@ static int gmin_get_config_var(struct device *maindev,
>         const struct dmi_system_id *id;
>         struct device *dev = maindev;
>         char var8[CFG_VAR_NAME_MAX];
> -       struct efivar_entry *ev;
> +       efi_status_t status;
>         int i, ret;
>
>         /* For sensors, try first to use the _DSM table */
> @@ -1326,24 +1326,11 @@ static int gmin_get_config_var(struct device *maindev,
>         for (i = 0; i < sizeof(var8) && var8[i]; i++)
>                 var16[i] = var8[i];
>
> -       /* Not sure this API usage is kosher; efivar_entry_get()'s
> -        * implementation simply uses VariableName and VendorGuid from
> -        * the struct and ignores the rest, but it seems like there
> -        * ought to be an "official" efivar_entry registered
> -        * somewhere?
> -        */
> -       ev = kzalloc(sizeof(*ev), GFP_KERNEL);
> -       if (!ev)
> -               return -ENOMEM;
> -       memcpy(&ev->var.VariableName, var16, sizeof(var16));
> -       ev->var.VendorGuid = GMIN_CFG_VAR_EFI_GUID;
> -       ev->var.DataSize = *out_len;
> -
> -       ret = efivar_entry_get(ev, &ev->var.Attributes,
> -                              &ev->var.DataSize, ev->var.Data);
> -       if (ret == 0) {
> -               memcpy(out, ev->var.Data, ev->var.DataSize);
> -               *out_len = ev->var.DataSize;
> +       status = EFI_UNSUPPORTED;
> +       if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
> +               status = efi.get_variable(var16, &GMIN_CFG_VAR_EFI_GUID, NULL,
> +                                         (unsigned long *)out_len, out);
> +       if (status == EFI_SUCCESS) {
>                 dev_info(maindev, "found EFI entry for '%s'\n", var8);
>         } else if (is_gmin) {
>                 dev_info(maindev, "Failed to find EFI gmin variable %s\n", var8);
> @@ -1351,8 +1338,6 @@ static int gmin_get_config_var(struct device *maindev,
>                 dev_info(maindev, "Failed to find EFI variable %s\n", var8);
>         }
>
> -       kfree(ev);
> -
>         return ret;
>  }
>



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux